Im a newbie. Sorry in advance. Here is the situation.
I have four tables:
Events (event_id, event, date, time, place, title)
Members (member_id, first_name, last_name, email, phone)
Positions (position_id, position)
List (list_id, member_id, event_id, position_id, calltime, pay)
The idea is to enter in all the members, all the events, all the positions into the appropriate tables.
Then I can take that information and quickly enter in the list table which person is working which event at a particular position.
Here is where I am stuck. Now I need an update page. On the update page, I need to call up a particular event and list the event information. Then I need to call up the list table and list all the members who are working that event, along with their positions, calltimes and pay.
I want the member_id and position fields to be a drop-down menus. I have created functions for these - which works. Here is the code for you to get an idea.
function namedropdown ($x)
{
$members = mysql_query("SELECT * FROM members ORDER BY last_name ASC");
while ($row = mysql_fetch_array($members))
{
if ($row["member_id"] == "$x")
{
printf("<option value=\"%s\" selected>%s, %s</option>\n", $row["member_id"], $row["last_name"], $row["first_name"]);
}
else
{
printf("<option value=\"%s\">%s, %s</option>\n", $row["member_id"], $row["last_name"], $row["first_name"]);
}
}
}
Now I can update a single row. But I can't update multiple rows and now I am confused...I've tried reading up on this, but it goes over my head. Here is my code so far...
<?php
include("dbconnection2.php");
if (!$event_id)
{
$result = mysql_query("SELECT *,DATE_FORMAT(date,'%m-%d-%Y') as FormatedDate FROM events ORDER BY date ASC",$db);
while ($myrow = mysql_fetch_array($result))
{
printf("<p>%s<br>\n", $myrow["FormatedDate"]);
printf("%s<br>\n", $myrow["event"]);
printf("[<a href=\"%s?event_id=%s\">update</a>]</p>\n", $PHP_SELF, $myrow["event_id"]);
}
}
else
{
if ($submit)
{
$sql = "UPDATE list SET member_id='$member_id',position_id='$position_id',calltime='$calltime' WHERE event_id=$event_id AND member_id=$member_id";
$result = mysql_query($sql);
echo "Information Updated.\n";
printf("<br>[<a href=\"viewnew.php\">View Records</a>]\n");
printf("[<a href=\"crewsubmit.html\">Add Records</a>]\n");
}
else
{
$sql = "SELECT * FROM events WHERE event_id=$event_id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form name="event" method="post" action="<?php echo $PHP_SELF?>">
<input type=hidden name="id" value="<?php echo $myrow["event_id"] ?>">
<table width="558" border="0" cellspacing="0" cellpadding="2">
<tr>
<td colspan="3">Event:<br> <input type="text" name="event" value="<?php echo $myrow["event"] ?>"></td>
</tr>
<tr>
<td colspan="3">Date:<br> <input type="text" name="date" value="<?php echo $myrow["date"] ?>"></td>
</tr>
<tr>
<td colspan="3">Time:<br> <input type="text" name="time" value="<?php echo $myrow["time"] ?>"></td>
</tr>
<tr>
<td colspan="3">Place:<br> <input type="text" name="place" value="<?php echo $myrow["place"] ?>"></td>
</tr>
<tr>
<td colspan="3">Title:<br> <input type="text" name="title" value="<?php echo $myrow["title"] ?>"></td>
</tr>
<?php
$list = mysql_query("SELECT * FROM list WHERE event_id=$event_id");
while ($myrow = mysql_fetch_array($list))
{
?>
<tr>
<td><select name="member_id"><?php namedropdown ($myrow[member_id]); ?></select></td>
<td><select name="position_id"><?php positiondropdown ($myrow[position_id]); ?></select></td>
<?php
printf("<td><input type=\"text\" name=\"calltime\" value=\"%s\"><td></tr>\n", $myrow["calltime"]);
}
?>
<tr>
<td colspan="3"><input type="Submit" name="submit" value="Update"></td>
</tr>
</table>
<input type=hidden name="updated" value="<?php echo $myrow["updated"] ?>">
</form>
<?php
}
}
?>
Where do I go from here? Or just start all over? Any help would be greatly appreciated.