How to query MYSQL when clicked?
I have a while statement, echoing my whole database that match a WHERE parameter. How can I make it so when I click on something (anything for the moment), it updates that specific row. Here's my code.
while($request = mysql_fetch_array( $request_db )) {
echo "<tr><td style=\"width:33%;padding:1px;\">";
echo $request['SongName'];
echo "</td><td style=\"width:33%;\">";
echo $request['Artist'];
echo "</td><td style=\"width:33%;\">";
echo $request['DedicatedTo'];
echo "</td><td style=\"width:33%;\">";
ec开发者_Go百科ho "UPDATE A ROW's 'Hasplayed' value to '1'.";
echo "</td></tr>";
}
echo "</table>";
Thanks!
EDIT: If you want an example, PHPmyAdmin can do this. Could I use some sort temporary cookie?
You can make a form and a button.
And update your table usual way, by handling this form with some PHP script.
You will need such a script anyway. Because no browser nor cookie can have access to your database. But only PHP script.
You can add to this script AJAX functionality later.
Give the rows an id and do an ajax request via a link with the id of the db element as parameter. The server script reloads that db id and returns the fresh database values. :)
精彩评论