Jump to content

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";

 

Link to comment
https://forums.phpfreaks.com/topic/292602-how-to-get-row-data-from-checkbox/
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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.