php复选框将歌曲添加到结帐页面

时间:2014-11-18 17:30:44

标签: php html psql

好吧,我想要在我的桌子上获取复选框,以便在检查和提交时将其重定向到checkout.php页面,然后显示已提交的歌曲。我的代码到目前为止

表格页面

<form action="checkout.php" method="POST">
<input type="submit" value="Submit">
</form>
</div>
<body>
<div id="col2">
<?php
error_reporting(~E_ALL);
  $conn = pg_connect("host=db.dcs.aber.ac.uk port=5432
  dbname=teaching user=csguest password=r3p41r3d");
  $res = pg_query ($conn, "SELECT artist, composer, genre, title, album, label, price,           description FROM music");
print'<form action="checkout.php" method="POST"><table>';
  print "<table border='1'>";
  print "<th></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($getColumn = pg_fetch_row($res))
{
print "<tr>";
print '<td><input type="checkbox" name="cart_items" value="1"></td>';
$active = isset($_POST['cart_items']) && $_POST['cart_items']  ? "1" : "0";
for ($j = 0; $j < pg_num_fields($res); $j++) {

print "<td>" . $getColumn[$j] . "</td>";
}

            print "</tr>";
}   
print '<input type="hidden" name="name"/>';
print '</table>'
?>

结帐页面

<?php 

//print_r($_POST);//print out the whole post
$cart_items = $_POST['cart_items'];

?>

0 个答案:

没有答案