jamesreno20 Posted November 14, 2014 Share Posted November 14, 2014 (edited) database.php $res = pg_query ($conn, "SELECT artist, composer, genre, title, album, label, price, description FROM music"); echo "<table border='1'>"; while($a = pg_fetch_array($res)){ echo "<td>" . $a['1'] . "</td>"; echo "<td>" . $a['2'] . "</td>"; echo "<td>" . $a['3'] . "</td>"; echo "<td>" . $a['4'] . "</td>"; echo "<td>" . $a['5'] . "</td>"; echo "<td>" . $a['6'] . "</td>"; echo "<td>" . $a['7'] . "</td>"; echo '<td><input type="checkbox" name="music[]" value="$ref"' . $row['0'] . $row['1'] . $row['2'] . $row['3'] . $row['4'] . $row['5'] . $row['6'] . $row['7'] . '"/></td>'; echo"</tr>"; } echo "</table>\n"; ?> <form action="shoppingbasket.php" method="POST"> Send To Basket: <name="music"> <input type="submit" value="submit"> </form> cant get it to send data from database to this page shoppingbasket.php if(isset($_POST['music'])){ if (is_array($_POST['music'])) { foreach($_POST['music'] as $row){ echo $row; } } else { $row = $_POST['music']; echo $row; } } Edited November 15, 2014 by mac_gyver code tags around posted code please Quote Link to comment https://forums.phpfreaks.com/topic/292471-error-wont-send-checkbox-value-to-next-page/ Share on other sites More sharing options...
mac_gyver Posted November 15, 2014 Share Posted November 15, 2014 while it is true you are using a PostgreSQL database, the problems you are having are related to the php code and the html you are producing from that php code. moving thread to the php coding help forum section. Quote Link to comment https://forums.phpfreaks.com/topic/292471-error-wont-send-checkbox-value-to-next-page/#findComment-1496659 Share on other sites More sharing options...
Barand Posted November 15, 2014 Share Posted November 15, 2014 (edited) To expand a variable inside a string the string has to be in double quotes. You have used single quotes. echo '<td><input type="checkbox" name="music[]" value="$ref"' Where is $row defined? Where is that input tag supposed to finish? Edited November 15, 2014 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/292471-error-wont-send-checkbox-value-to-next-page/#findComment-1496664 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.