mysql - PHP Basket quantity variable -
i trying create php page materials database populated. users should able enter quantity next item wish order , have created qty text field this
<?php session_start(); include("db.php"); $pagename="order material"; echo "<html>"; echo "<title>".$pagename."</title>"; echo "<h2>".$pagename."</h2>"; include ("detectlogin.php"); echo "<link rel=stylesheet type=text/css href=mystylesheet.css>"; $sql="select * material"; $result=mysqli_query($con, $sql) or die(mysqli_error($con)); echo "<table border=1>"; echo "<tr>"; echo "<th>material name</th>"; echo "<th>material description</th>"; echo "<th>toxicity level</th>"; echo "</tr>"; while ($arraymaterials=mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>".$arraymaterials['materialname']."</td>"; echo "<td>".$arraymaterials['materialdescrip']."</td>"; echo "<td>".$arraymaterials['materialtoxicity']."</td>"; echo "<td>enter quantity</td>"; echo "<td><input type=text name=qty value=qty size=5></td>"; echo "<form action=request_material.php method=post>"; echo "<input type=hidden name=materialcode value=".$arraymaterials['materialcode'].">"; echo "<td><input type=submit value='request'></td>"; echo "</form>"; echo "</tr>"; } echo "</table>"; ?>
however, cannot post value of qty on next page though have $qty=$_post['qty']; on request_material.php. know why value entered in qty field cannot posted onto request_material.php page? need session variable?
thanks
because input tag name="qty"
outside form tag
echo "<td><input type=text name=qty value=qty size=5></td>";// outside form tag echo "<form action=request_material.php method=post>"; echo "<input type=hidden name=materialcode value=" . $arraymaterials['materialcode'] . ">"; echo "<td><input type=submit value='request'></td>"; echo "</form>";
you need add inside form tag
as
echo "<form action=request_material.php method=post>"; echo "<td><input type=text name=qty value=qty size=5></td>";// add inside echo "<input type=hidden name=materialcode value=".$arraymaterials['materialcode'].">"; echo "<td><input type=submit value='request'></td>"; echo "</form>";
Comments
Post a Comment