Forum Moderators: open
Let me elaborate on the situation.
I have a table of data that is generated, these are entries on a calender that I want in list format. I have an attendee column in this table of data and I have built functionality that allows people to click "participate" and the user is added via MySQL as a participant to the event. The table instantly is up to date (Ajax).
There is only one problem in this. I don't know how to specify only the event the user clicked on. Right now I just have a MySQL statement that updates all of the events. I just wanted to make sure I could do it. Now that I have, I need to know how to specify the exact event.
It is clear which event the user wants to participate in, I just don't know how to send that specific array value to the external MySQL statement in PHP file.
Note: Echo's need to be there, they just do =).
The data table with the arrays.
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
$row['date']=substr($row['date'],4,2) . "/" . substr($row['date'],6,2) . "/" . substr($row['date'],0,4);
echo "<td>" . $row['date'] . "</td>";
$row['time']=substr($row['time'],0,2) . ":" . substr($row['time'],2,2);
echo "<td>" . $row['time'] . "</td>";
echo "<td><a href='#' onclick='ajaxFunction2()'>" . $row['created_by'] . "</a></td>";
echo "<td>" . $row['participants'] . "<img src='new.gif' onmouseover='ajaxFunction2()' onclick='ajaxFunction()' />
</td>";
echo "</tr>";
}
echo "</table>";
This is the SQL that updates the participants column. Notice I just have the static value of "admin". I need this to specify a specific array vallue, whether it be a unique ID or the event name, it doesn't matter, I just need to know how to send the array value to the SQL statement.
"UPDATE entry SET participants='$useraccount' WHERE create_by='admin'"
Thanks in advance, I appreciate any help.
echo "<td><a href='#' onclick='ajaxFunction2()'>" . $row['created_by'] . "</a></td>";
I'd suggest to have the ajaxFunction pass the ID of the event to the server side script.
echo "<td><a href='#' onclick='ajaxFunction2(" . $row['eventID']. ")'>" . $row['created_by'] . "</a></td>"; JavaScript:
function ajaxFunction2(eventID) {
// (myreq is the HTTP-request object)
myreq.open("GET", 'http://' + location.hostname + '/script.php?eventID=' + eventID, true);
myreq.send();
}
The eventID parameter should now be available to your PHP script:
$_GET['eventID'].
[edited by: RonPK at 11:08 am (utc) on July 13, 2007]