Jump to content

[SOLVED] Looping Option Form


topflight

Recommended Posts


<?php

//database connection.
$db=mysql_connect("localhost","username","password");
$db_res=mysql_select_db("db_name",$db);

//form out off loop

echo"<form method='POST' method=' '>";

//select every database field names.

$sql="SELECT * FROM what_ever";

$sql_res=mysql_query($sql)or die(mysql_error());

// loop all from select statement

while($row=mysql_fetch_assoc($sql_res)){

//echo al the names.
echo "<input type='text' name='name' vlaue='{$row["name"]}'>";

// submit each name if need be. button named submit.
//echo"<input type='submit' name='submit' value='send'>"; 

}

// submit all the names if need be. button named submit.
echo"<input type='submit' name='submit' value='send'>"; 

?>

called a select box mate, the other was a text box example.


<?php

//database connection.
$db=mysql_connect("localhost","username","password");
$db_res=mysql_select_db("db_name",$db);

//form out off loop

echo"<form method='POST' method=' '>";

//select every database field names.

$sql="SELECT * FROM what_ever";

$sql_res=mysql_query($sql)or die(mysql_error());


//start select box.

<select name='name'>

// loop all from select statement

while($row=mysql_fetch_assoc($sql_res)){

//echo al the names.
echo "<option  vlaue='{$row["name"]}'>{$row["name"]}<option>";

}

// end select .

<select>

// submit names if need be. button named submit.
echo"<input type='submit' name='submit' value='send'>"; 

?>

Archived

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

×
×
  • 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.