TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-05-2009, 08:21 PM   #1 (permalink)
The Visitor
Newcomer 
 
Join Date: May 2009
Posts: 1
Thanks: 0
xxtokerxx is on a distinguished road
Default 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
xxtokerxx is offline  
Reply With Quote
Old 05-05-2009, 08:32 PM   #2 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by xxtokerxx View Post
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>";
}
allworknoplay is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Injection and mysql_real_escape_string Durux General 61 01-29-2013 12:20 PM
Importing an SQL dump via PHP delayedinsanity MySQL & Databases 1 07-21-2008 05:59 PM
SQL injections protection Rendair Tips & Tricks 23 12-11-2007 03:59 PM
Export as SQL from mySQL using cron job datahound MySQL & Databases 5 12-08-2007 12:18 AM
SQL Query?? Tanax Absolute Beginners 11 11-21-2007 06:45 PM


All times are GMT. The time now is 09:43 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design