jamesreno20 Posted November 20, 2014 Share Posted November 20, 2014 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 More sharing options...
Barand Posted November 20, 2014 Share Posted November 20, 2014 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. Link to comment https://forums.phpfreaks.com/topic/292602-how-to-get-row-data-from-checkbox/#findComment-1497144 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.