Jump to content

Recommended Posts

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 by mac_gyver
code tags around posted code please

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 by Barand
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.