Click here to Skip to main content
15,885,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<select>
    
        <option value="<?php echo $row['coloumn1']; ?>">
        <?php echo $row['coloumn1']; ?>
        </option>
     
</select>


this is what i have now.... and i need inside this while loop check every row value with previous all(rows) and compare. If its match means put tat group value in drop down list... Remaining value must displayed as text view....


PHP
 <form method="get" action="inc.php">
<table id="resultTable" data-responsive="table">
	<thead>
		<tr>
			<th> Product Code </th>
			<th> Product Name </th>
			<th> Qty </th>
			<th> Price </th>
		</tr>
	</thead>
	<tbody>
   
		
             while($row = mysqli_fetch_array($sres))
			 
			 //while($row!=0)
                        {			
			 
			<tr class="record">
			<input type="text" name="productcode[]" id="productcode" value="<?php echo $row['product_code']; ??>" readonly>
			<td><input type="text" name="productname[]" id="productname" value="<?php echo $row['product_name']; ??>" readonly>
                        </td>
			<td><label for="qty"></label>
			  <input type="text" name="qty[]" id="qty" value="1"></td>
			<td>
						$ppp=$row['price'];
			
			 
	            	<input type="text" name="price[]" id="price" value="<?php echo $ppp;??>" readonly>
			</td>	
							 }
			            
			<tr>
				<td colspan="4">Total:</td>
				</tr></tr></tbody></table> <br>
                <input type="submit" id="calculate" name="calculate" value="Calculate">
				
 } 
<br>
</form> 
Posted
Updated 19-Apr-14 1:55am
v3

1 solution

use a while loop to loop thru the recordsets returned from sql query and echo each row into the option of a select tag, refer: populate-drop-down-list-from-database-using-mysqli-prepared-statements[^]
+++++++++++++++++++++++++[round 2]
How do you construct dropdownlist in html? see example:
<select>
  <option value="1">pencil</option>
  <option value="2">eraser</option>
  <option value="3">paper</option>
</select>

So in your php script, you have to loop to populate the options from the recordset retrieved from the database, so use while loop, example:
XML
<?php
     while($row = mysqli_fetch_array($sres)){
?>
    <option value="<?php echo $row['product_code'] ?>">
          <?php echo $row['product_name'] ?>
     </option>
<?php
    }
?>

You php script will interwind with html to create the html output of the select dropdownlist. You got to have a good knowledge of html first so that you know how to construct them using php.
 
Share this answer
 
v3
Comments
Arun2012 19-Apr-14 5:00am    
i need more detail about your link
Peter Leow 19-Apr-14 7:45am    
See my addition to solution 1. You got to be patient as I am full-time into this.
Arun2012 19-Apr-14 7:59am    
See my updated question... will you get my question?
Peter Leow 19-Apr-14 8:11am    
I have already seen it. I have already given the necessary guide for creating the dropdown list. Good luck.
Arun2012 22-Apr-14 0:45am    
I know how to creating the dropdown list, but the dropdown list only appear when the condition satisfied
$row['product_name']is same as previous $row['product_name'] entries.
Note: I need create an array inside the while loop then compare tat array list if repeated entries appear then we put tat repeated value into dropdown list How?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900