Hi there,
I've got a a form that includes several drop downs which are generated from rows within a database, which works fine thanks to the very helpful folks on this forum.
Some of these drops downs are not compulsory and I would like them to be left blank if not needed - or with a default "please select...".
Is this possible with the following code
Secondly, if that person doesn't select anything I don't want anything added to the database. I suspect that even if the user doesn't select an option, then a blank row, or a row containing the phrase "please select" will be entered. Is there a way around this?
Many thanks. I hope it makes sense.
I've got a a form that includes several drop downs which are generated from rows within a database, which works fine thanks to the very helpful folks on this forum.
Some of these drops downs are not compulsory and I would like them to be left blank if not needed - or with a default "please select...".
Is this possible with the following code
Code:
<?
include("connect.php");
$query="SELECT categoryName FROM category";
$result = mysql_query ($query);
echo "<select name='eventCategory2'></option>";
while($nt=mysql_fetch_array($result)){
echo "<option value='$nt[categoryName]'>'$nt[categoryName]'</option>";
}
echo "</select>";
?>
Secondly, if that person doesn't select anything I don't want anything added to the database. I suspect that even if the user doesn't select an option, then a blank row, or a row containing the phrase "please select" will be entered. Is there a way around this?
Many thanks. I hope it makes sense.
Comment