What I am attempting to do is, have the user register his team members.
This is the logged in page that I have working. If the user wishes to add or manage his team he clicks the link Add/Manage.
HELLO MILLERN !You are currently logged in.Click here to Add/Manage Collegiate TeamClick here to log out.
The Add/Manage link takes the user to this page:
10k Men Action
Andrew Mayor view | edit | delete
Add male runner
6k Women Action
Beth Miller view | edit | delete
Add female runner
At this page the user can add runners to both the male and female categories as well as delete or edit their information. Initially the Men and Women will be blank if the user has never placed in information. My issue is this: once the user has lets say entered in several runners into each category how do I get the tables to pull up dynamically the correct information so that the user can see who he has registered.
My database has two tables one titled users this is where the registration information is kept when an individual desires to create a login username and password. The structure of this is bellow:
id int(11) No auto_increment
login varchar(25) No
pw varchar(32) No
firstName varchar(32) No
lastName varchar(32) No
email varchar(50) No
address varchar(64) No
city varchar(32) No
state varchar(32) No
zip varchar(16) No
phone varchar(16) No
divisionType enum('collegiate','highschool') No collegiate
assistCoachName varchar(32) No
assistCoachEmail varchar(32) No
lastChange datetime No 0000-00-00 00:00:00
tmp_mail varchar(50) No
active enum('y','n') No n
The other table is titled, collegiate in this table I have a ‘id’ and ‘user_id’ my plan is to tie in the id from this table to match the users table id and the user_id will be specific to the person who registered the members in this table. Because I am going to have hundreds of users I need to keep track so when the user comes to view/edit/del he can be linked to the correct people under his team. Another thing is because there are two categories one for men and women I have included a gender field for when the user clicks to add either male of female runner in the gender so that I can keep track of that as well for when I want it to display.
id int(11) No auto_increment
user_id int(11) No 0
firstName varchar(50) No
lastName varchar(50) No
year varchar(16) No
age varchar(16) No
gender enum('m','f') No m
last_change datetime No 0000-00-00 00:00:00
The only code I have written thus far is bellow but I am not sure on how to get all this to work. I am trying to take it little bits at a time but I need some advice and help on how to accomplish this. Bellow is the code that I have written:
<?php
include($_SERVER['DOCUMENT_ROOT']."/user/access_user_class.php");
error_reporting (E_ALL); // I use this only for testing
$update_profile = new Users_profile;
$update_profile->access_page($_SERVER['PHP_SELF'], $_SERVER['QUERY_STRING']); // protect this page too.
$error = $update_profile->the_msg; // error message
// del
if(isset($_GET['del']))
{
// remove the article from the database
$query = "DELETE FROM collegiate WHERE id = '{$_GET['del']}'";
mysql_query($query) or die('Error : ' . mysql_error());
// then remove the cached file
$cacheDir = dirname(__FILE__) . '/cache/';
$cacheFile = $cacheDir . '_' . $_GET['id'] . '.html';
@unlink($cacheFile);
// and remove the index.html too because the file list
// is changed
@unlink($cacheDir . 'index.html');
// redirect to current page so when the user refresh this page
// after deleting an article we won't go back to this code block
header('Location: ' . $_SERVER['PHP_SELF']);
exit;
}
?>
<?php
// the 'user_id' a field value in the collegiate table/ 'id' is the field value of the user,
// both the collegiate table and user table have field named 'id' which contains the same value
$_SESSION['user_id'] = $this->id;
$query = sprintf("SELECT id, firstName, lastName, year, age FROM %s WHERE users_id = %s", collegiate, $this->id);
$result = mysql_query($query) or die('Error : ' . mysql_error());
?>
<table width="600" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#999999">
<tr align="center" bgcolor="#CCCCCC">
<td width="500"><strong>10k Men </strong></td>
<td width="150"><strong>Action</strong></td>
</tr>
<?php
while ((list($id, $firstName, lastName, year, age)= mysql_fetch_array($result, MYSQL_NUM))
{
?>
<tr bgcolor="#FFFFFF">
<td width="500">
<?php echo $firstName;?>
</td>
<td width="150" align="center"><a href="article2.php?id=<?php echo $id;?>" target="_blank">view</a>
| <a href="cms-edit.php?id=<?php echo $id;?>">edit</a> | <a href="javascript:delArticle('<?php echo $id;?>', '<?php echo $firstName;?>');">delete</a></td>
</tr>
<?php
}
?>
</table>
<p align="center"><a href="cms-add.php">Add runner</a></p>