Link to home
Start Free TrialLog in
Avatar of MirageSF
MirageSF

asked on

Loading LIST Menus with data from database

Hi,

<form name="form1" method="post" action="">
                    <select name="select">
                      <option value="<?php $selected="domain 1";print mysql_result($result,0,"domain");?>" selected><?php print mysql_result($result,0,"domain");?></option>
                      <option value="<?php $selected="domain 2";print mysql_result($result,1,"domain");?>"><?php print mysql_result($result,1,"domain");?></option>
                    </select>
                    <input type="submit" name="Submit" value="SHOW">
                  </form>

Im using the code above to force 2 rows of data into the list menu, how do I get the list menu to auto populate from the rows in the database ?

When one is actually selected and the Submit button is clicked it also needs to set the $selected variable to the domain name selected.

Thank
Avatar of MirageSF
MirageSF

ASKER

Actually, be better if $selected = 0 for first item on list, then 1, 2 and so on
ASKER CERTIFIED SOLUTION
Avatar of Diablo84
Diablo84

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sigh, im not having much luck today

you can remove $num = 0; you don't need it.
>> When one is actually selected and the Submit button is clicked it also needs to set the $selected variable to the domain name selected.

$selected = $_POST['domain'];

The post value of domain will contain the domain name that was selected in the drop down list
Hi Diablo84,

I used a slightly smaller piece of code that seems to do the trick nicely, seems its all pretty much working as planned at the moment...

http://www.stormfusion.com/dms.php
L=DMS-001-1000
P=test

Except for the DOMAIN link, it currently links to http://www.stormfusion.com/domainone.com for some reason, it should be http://www.domainone.com.  The $domain variable only contains the domainone.com part and not the http://www.

Im using the code as...

<?php echo "<a href='" . mysql_result($result3,0,"domain") . "'>" . mysql_result($result3,0,"domain") . "</a>"; ?>

Once this is fixed I will close the question.

Thankyou
unless you have the http:// protocol in front of the domain it will simple regard is as a link within your site so you would have to do something like:

<?php echo "<a href='http://" . mysql_result($result3,0,"domain") . "'>" . mysql_result($result3,0,"domain") . "</a>"; ?>