Jump to content

drop down menu


hmark

Recommended Posts

I'm trying to insert a dropdown menu on my webpage. THis is what I have right now:

 

[code=php:0]
<tr>
<td>System:</td>
<td><select name="system">
<option value=""> </option>
<?
$arr_system = getFldArray("system");
foreach ($arr_system as $f){
	print "<option value=\"$f\">$f</option>";
}
?>
<td>
</tr>

[/code]

 

When i execute this, I get varchar(20) as a option. Anyone have any suggestions? I know very very very little php and mysql. I appreciate any help. I hope I posted enough info (and that I posted it correctly  :confused: thanks.

Link to comment
https://forums.phpfreaks.com/topic/188275-drop-down-menu/
Share on other sites

I defined it as:

 

function getFldArray($f){
$q = "describe experts $f";
$res = run_query($q);
$row = mysql_fetch_array($res);
$rt = $row['Type'];
$rt = preg_replace('/enum\(\'/', '', $rt);
$rt = preg_replace('/\'\)/', '', $rt);
$arr = explode('\',\'',$rt);
sort($arr);
return $arr;
}

Link to comment
https://forums.phpfreaks.com/topic/188275-drop-down-menu/#findComment-994243
Share on other sites

  • 2 weeks later...

what I was trying to say earlier was, the mysql query you are running is saying 'describe this field', and the description of those fields in the database is 'varchar[20]'.  You need to run a query on the actual data, i.e. 'select type from experts..' or whatever data you are trying to fetch from the sql statement....

Link to comment
https://forums.phpfreaks.com/topic/188275-drop-down-menu/#findComment-1004518
Share on other sites

This is what I use for one

 

<select name="market">
		<option value="none" selected>Please select a market</option>
		<?php

//for each row we get from mysql, echo a form input
while ($row = mysql_fetch_array($result)) {
echo "<option value=\"".$row['market']."\">{$row['market']}</option>\n";
}
?> </select>

 

$result is just a select all on the markets table

Link to comment
https://forums.phpfreaks.com/topic/188275-drop-down-menu/#findComment-1004523
Share on other sites

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.