Hey,
is it possible to create form , and the options are information from mysql , and when they press the submit button, php will take the selected option and add it to database?
I have tried to do this, but it does a form for each result,
e.g.
for a form i query the database for different types, so u would get
action
sci-fi
horror
etc
and then i add into form the query
Creating a form
Moderator: General Moderators
hi
the code
thanks
the code
Code: Select all
<?php
$db =mysql_connect("localhost","", "");
mysql_select_db("",$db);
$sql3 = "SELECT * FROM fansub ";
$rs3=mysql_query($sql3,$db)or die("Cannot query the database.<br>" . mysql_error());
while ($r3 = mysql_fetch_array($rs3))
{
$fansub_name=$r3["fansub_name"];
$web_link=$r3["web_link"];
$irc=$r3["irc"];
?>
<select name="fansub_name">
<option value="<?php echo $fansub_name;?>"><?php echo $fansub_name;?></option>
</select>
<?php
}
?>if you put the <select>-tag within the while-loop for each record a new <select> will be put to the output stream.
Code: Select all
<select name="fansub_name">
<?php
while ($r3 = mysql_fetch_array($rs3))
{
...
?>
<option value="<?php echo $fansub_name;?>"><?php echo $fansub_name;?></option>
<?php
}
?>
</select>