<?PHP
$query = "SELECT event.eventcustomer,event.description,event.date_event,event.event_id FROM event,dbACT WHERE event.eventcustomer=dbACT.Contact AND dbACT.ID='$user_id2' ORDER BY event.date_event ASC";
$result = mysql_query($query);
while(list($eventcustomer,$description,$deadline,$eid) = mysql_fetch_row($result))
{
?>
<tr align="left">
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
First of all, you didn't say what the problem you're having actually is. "It doesn't work" isn't very helpful; you really should be catching query errors so you know exactly what's going on with your queries.
PHP Code:
$queryString = "UPDATE event SET complete='$eidtext' WHERE event_id='$eid'";
$query = mysql_query($queryString);
if (!$query) {
die("Query Error! Query string: $queryString<br />Error: ".mysql_error());
}
Now then, to the actual problem: I see you are creating this HTML inside a loop:
There are two problems with this. First, each element in your DOM needs to have a unique ID value. You are assigning multiple input elements the id "eid". That's going to cause issues.
Second, the name "eid[event_id]" is not going to change on each iteration in your loop, so you're going to end up with only one entry in your $_POST array.
To see how PHP is interpreting your form elements over to the $_POST array, use this:
PHP Code:
echo "<pre>".print_r($_POST,true)."</pre>";
That'll be helpful in figuring out how to process the data and eventually get to updating the database.
Thanks for the reply Fumigator, by 'not working' I should have explained that the UPDATE event query updates the complete field with a blank value.
Removing the [event_id] and setting the complete field to equal $eid returns correctly the $eid value of the highest id. In my case 4. So the last row of the db is updated with the complete value as 4 (which is correct as the ID of this row is 4)
From this I presume I need a way to make each textbox a unique ID that I can then refer to when I post?
This is my idea ... everyone else beat me to the post.
Examine all of the ideas and put together a plan.
You'll want to use an array for both the checkboxes and textboxes.
The value of the checkbox will be an index number ...
With PHP, when you process the checkbox array, the array will only
contain the boxes that were checked. So in your example where you
are showing box 1 and 3 checked ... the checkbox array will only have
two items in it. You won't know which ones were checked, so you need
to example the values of them ... and then you know.
This is my idea ... everyone else beat me to the post.
Examine all of the ideas and put together a plan.
You'll want to use an array for both the checkboxes and textboxes.
The value of the checkbox will be an index number ...
With PHP, when you process the checkbox array, the array will only
contain the boxes that were checked. So in your example where you
are showing box 1 and 3 checked ... the checkbox array will only have
two items in it. You won't know which ones were checked, so you need
to example the values of them ... and then you know.