From a table on mysql, i have listed specific rows. There are two PK's, (DRUG_ID,BRANCH_ID)
I want to select certain rows, and display them on another form.
e.g.
DID BID STOCK
1 1 3
1 2 4
2 1 6
2 2 5
I have tried a few different ways and none have worked. This is what i currently have
Form 1
Code: Select all
$result2 =mysql_query("SELECT ....");
echo "<form action= conorder.php method=POST>";
echo "<table border='1'>";
echo "<tr> <th>DRUG ID</th> <th>Branch ID</th><th>STOCK</th></tr>";
$counter=0;
while($row = mysql_fetch_array( $result2 )) {
echo "<tr><td>";
echo "<input type='hidden' name=drug_id[$counter] value='$row[drug_id]'>";
echo $row['drug_id'];
echo "</td><td>";
echo "<input type='hidden' name=branch_id[$counter] value='$row[branch_id]'>";
echo $row['branch_id'];
echo "</td><td>";
echo "<input type='hidden' name=total_stock[$counter] value='$row[total_stock]'>";
echo $row['total_stock'];
echo "</td><td>";
echo "<input type=checkbox name=ticked[] value='$counter'>";
echo "</td></tr>";
$counter++;
}
echo "</table>";
echo "<input type =submit value= Submit>";
echo "<input type = reset>";
echo "</form>";Code: Select all
if (isset($_POST['ticked'])) {
for ($i=0; $i<count($_POST['ticked']); $i++) {
echo "<br>drug id: ";
echo $_POST[drug_id][$i];
echo " branch id: ";
echo $_POST[branch_id][$i];
echo " stock: ";
echo $_POST[total_stock][$i];}
}If for example i select rows 2 and 3, I get rows 1 and 2.
Or if i select row 4, i get row 1.
Where have i gone wrong?