I have a mysql table. I have created a html table and filled it with data from my mysql table using php and sql. I then want to be able to click a checkbox next to each row of data, and click edit, and be able to edit the data all from the webpage.
Code which i used to build the html table and fill it with mysql data:
$result = mysql_query("SELECT * FROM table");
if (mysql_num_rows($result)>0){
$r = mysql_fetch_array($result,MYSQL_ASSOC);
$table="<table><tr style='background:#cccccc;'>";
$firstLine="<tr>";
foreach ($r as $k => $v){
$table .="<td style='border:1px #ffffff solid;'>".$k."</td>";
$firstLine .="<td>".$v."</td>";
}
$table.="</tr>".$firstLine."</tr>";
while($r = mysql_fetch_array($result,MYSQL_ASSOC)){
$table.="<tr>";
foreach($r as $k => $v)
$table.="<td>".$v."</td>";
$table.="</tr>";
}
$table .="</table>";
echo $table;
}
Can anyone help provide me with any guidance which will help me achieve this?
put each piece of data that could be changed into a text input, instead of just as text, with the value attribute what’s coming from the db and a name which can identify it. That way, you can check the box next to the text input and change it. when the data is sent to the server, anytime a checkbox is checked, that’s a row that will change in the db.