Jump to content

for loop did not work


newphpcoder

Recommended Posts

Hi..I am new in using for loop to get the values from while loop:here is my code:

$sql = "SELECT DISTINCT Items FROM bom_subitems ORDER BY Items";$res_bom = mysql_query($sql, $con);while($row = mysql_fetch_assoc($res_bom)){       $Items = $row['Items'];echo "<tr>	    <td style='border: none;font-weight: bold;'> <input type='name' value='$Items' name='Items[]' id='Items' readonly = 'readonly' style = 'border:none;width:auto;font-family: Arial, Helvetica, sans-serif;font-size: 1em;' size='5'></td>	    <td style='border:none;'> </td>	    <td style='border:none;'> </td>	    <td style='border: none;'><center><input type='text' name='DemandedQty' id='DemandedQty[]' value='' size='7'></center></td>	   	    </tr>";	  }

sample:Items -- I input demanded qtyP28 -----1P30------2P32------3when I debug my script by checking if what data was get bhy using for loop:

$Items = $_POST['Items'];$DemandedQty = $_POST['DemandedQty']; for($s = 0; $s <= count($Items); $s++){   echo $DemandedQty[$s];echo '<br/>';echo $Items[$s];				   }

the ouput is:3P28P30P32I don't know why only the last demanded qty was get.I want output is :P28- 1P30- 2P32 - 3Thank you

Link to comment
Share on other sites

Dump POST content and see if your data is even being sent.var_dump($_POST);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...