TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Drop down relationship to SQL? (http://www.talkphp.com/absolute-beginners/4231-drop-down-relationship-sql.html)

xxtokerxx 05-05-2009 08:21 PM

Drop down relationship to SQL?
 
Hope you can help me on this one,

I want to create a drop down list (1 field) which ties into a database(SQL?) essentially this is the HTML variation of what I have but I want the site to be more dynamic.

<form name="nav">
<select style=
"font-size:12px;
color:#006699;
font-family:verdana;
background-color:#ffffff;
" name="menu" onChange="location=document.nav.menu.options[document.nav.menu.selectedIndex].value;">
<option value=''>Please choose</option>
<option value="test1.html">test1</option>
<option value="test2.html">test2</option>
<option value="test3.html">test3</option>
</select>
</form>



When the user clicks on test1 they are taking to test1.html


Essentially, I want the drop down to "autoselect" the fields from the database so all the options are available without addition of hard coding.

and then require the contents of this "entry" to display on the website.


Any ideas?

BTW I am not too good with sql, php etc. just learning

allworknoplay 05-05-2009 08:32 PM

Quote:

Originally Posted by xxtokerxx (Post 23689)
Hope you can help me on this one,

I want to create a drop down list (1 field) which ties into a database(SQL?) essentially this is the HTML variation of what I have but I want the site to be more dynamic.

<form name="nav">
<select style=
"font-size:12px;
color:#006699;
font-family:verdana;
background-color:#ffffff;
" name="menu" onChange="location=document.nav.menu.options[document.nav.menu.selectedIndex].value;">
<option value=''>Please choose</option>
<option value="test1.html">test1</option>
<option value="test2.html">test2</option>
<option value="test3.html">test3</option>
</select>
</form>



When the user clicks on test1 they are taking to test1.html


Essentially, I want the drop down to "autoselect" the fields from the database so all the options are available without addition of hard coding.

and then require the contents of this "entry" to display on the website.


Any ideas?

BTW I am not too good with sql, php etc. just learning

Yeah just use a loop to display your database results.



Code:


Ex:


(your SQL query)


while($rows = mysql_fetch_array($results)) {

echo "<OPTIONS value=\"$page_index\">$page_name</OPTIONS>";
}



All times are GMT. The time now is 02:04 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0