Jump to content

Archived

This topic is now archived and is closed to further replies.

jamesreno20

how to get row data from checkbox

Recommended Posts

  i have checkbox in a table and want to put the value as the id in the database then when i press submit it displays all the row data for each checkbox 
 
$res = pg_query ($conn, "SELECT artist,composer,genre,title,album,label,price,description FROM music");
echo "<table border='1'>";
echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>";
 while ($row = pg_fetch_row($res)) 
 {
 echo "<tr>";
 echo '<td><input type="checkbox" name="check_list[]" value="' . $row['res'] .'"></td>';
 for ($column = 0; $column < pg_num_fields($res); $column++) 
 {
 echo "<td>" . $row[$column] . "</td>";
 }
 echo "</tr>";
 }
 echo "</table>\n";
 
________________________________________________--
basket.php
 
echo "<table border='1'>";
echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>";
 
echo "<pre>\n";
print_r($_POST['check_list']);
echo "</pre>\n";

 

Share this post


Link to post
Share on other sites

There is no column "res" in your results (you didn't select one with that name or use it as an alias) so $row['res'] has no value.

 

Select the id  along with the other columns and use that as the value.

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.