Jump to content

for loop did not work


newphpcoder
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...