Jump to content

Repeatition for drop down list


s4salman

Recommended Posts

I want to repeat this form 40 times. Can any body help me with php code. Below, is the one row printing 06 drop down list. I want to repeat this thing 40 times. What is mean is that repeate this 06 drop down field 40 times.

<tr>
<td width="100%" ALIGN="CENTER">

description<input type="text" name="description">
</td>
</tr>

</table>

<table border="0" cellpadding="2" cellspacing="8">



<tr>


<td width="10%" ALIGN="CENTER">


		<label  for="element_1"> </label>
		<div>
<?php 
   
$sql="SELECT * FROM tutorial order by field1"; 


/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */

echo "<select name=stepa>"; // list box select command

foreach ($dbo->query($sql) as $row){//Array or records stored in $row

echo "<option value=$row[field1]>$row[field1]</option>"; 

/* Option values are added by looping through the array */ 

}

 echo "</select>";// Closing of list box

?>


</div> 
		

</td>


<td width="20%" ALIGN="CENTER">


		<label  for="element_1"> </label>
		<div>
 
 
<?php
  
$sql="SELECT * FROM tutorial order by field2"; 


/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */

echo "<select name=stepa>"; // list box select command

foreach ($dbo->query($sql) as $row){//Array or records stored in $row

echo "<option value=$row[field2]>$row[field2]</option>"; 

/* Option values are added by looping through the array */ 

}

 echo "</select>";// Closing of list box

?>


</div> 
		

</td>


<td width="10%" ALIGN="CENTER">


		<label  for="element_1"> </label>
		<div>
 
 
<?php
  
$sql="SELECT * FROM tutorial"; 


/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */

echo "<select name=stepa>"; // list box select command

foreach ($dbo->query($sql) as $row){//Array or records stored in $row

echo "<option value=$row[field3]>$row[field3]</option>"; 

/* Option values are added by looping through the array */ 

}

 echo "</select>";// Closing of list box

?>


</div> 
		

</td>




<td width="10%" ALIGN="CENTER">


		<label  for="element_1"> </label>
		<div>
<?php 
   
$sql="SELECT * FROM tutorial order by field1"; 


/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */

echo "<select name=stepa>"; // list box select command

foreach ($dbo->query($sql) as $row){//Array or records stored in $row

echo "<option value=$row[field1]>$row[field1]</option>"; 

/* Option values are added by looping through the array */ 

}

 echo "</select>";// Closing of list box

?>


</div> 
		

</td>


<td width="20%" ALIGN="CENTER">


		<label  for="element_1"> </label>
		<div>
 
 
<?php
  
$sql="SELECT * FROM tutorial order by field2"; 


/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */

echo "<select name=stepa>"; // list box select command

foreach ($dbo->query($sql) as $row){//Array or records stored in $row

echo "<option value=$row[field2]>$row[field2]</option>"; 

/* Option values are added by looping through the array */ 

}

 echo "</select>";// Closing of list box

?>


</div> 
		

</td>


<td width="10%" ALIGN="CENTER">


		<label  for="element_1"> </label>
		<div>
 
 
<?php
  
$sql="SELECT * FROM tutorial"; 


/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */

echo "<select name=stepa>"; // list box select command

foreach ($dbo->query($sql) as $row){//Array or records stored in $row

echo "<option value=$row[field3]>$row[field3]</option>"; 

/* Option values are added by looping through the array */ 

}

 echo "</select>";// Closing of list box

?>


</div> 
		

</td>

</tr>
Link to comment
Share on other sites

I want to repeat this form 40 times.

 

 

probably not. there's two problems with this. 1) no one is likely to want to go through 40 or 6 * 40, depending on what your statement about what you are doing means, different select/option menus (there's probably a better interface to do this), and 2) this shows that your database table has designed badly.

 

so, what does this data actually represent and how many select/option menus are there in each form and how many forms are there?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.