473,395 Members | 1,556 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

dropdown data from sql

ddtpmyra
333 100+
Im used of doing a dropdown menu on a hardcoded choices...

Expand|Select|Wrap|Line Numbers
  1.  <b>Select Category:
  2.    <select name="category">
  3.                  <option value="Category 1">Process Change</option>
  4.                  <option value="Category 2">Product Update</option>
  5.   </select></b>
but how can you do a dropdown menu using query result. Can somebody show me how I would apprecite this :)
Nov 25 '08 #1
3 1489
pbmods
5,821 Expert 4TB
Heya, ddtpmyra.

Here you go:
php dropdown from query - Google Search
Nov 25 '08 #2
ak1dnar
1,584 Expert 1GB
Here are more of them. from Bytes Forum.
site:bytes.com php drop down - Google Search
Nov 25 '08 #3
ddtpmyra
333 100+
I found my way how to work on this... just in case for other bytes members looking for formats or scripts
Expand|Select|Wrap|Line Numbers
  1. //Connect to the database
  2.  
  3. //THIS CHECKS IF YOU’VE ALREADY SELECTED CONTACT NAME FOR INSTANCE
  4. if(!isset($_GET['CONTACT'])){ 
  5. $Var ='%'; 
  6. else 
  7. if($_GET['CONTACT'] == "ALL"){ 
  8. $Var = '%'; 
  9. } else { 
  10. $Var = $_GET['CONTACT']; 
  11.  
  12. //THIS PUTS A FORM WITH A drop down BOX TO SELECT THE CONTACT AND SHOW THE CONTACT IF ALREADY SELECTED 
  13.  
  14. echo "<form action=\"XXX.php\" method=\"GET\"> 
  15. <b>Contact</b>"; 
  16. $res=mysql_query("select * from contacts"); 
  17. if(mysql_num_rows($res)==0){ 
  18. echo "there is no data in table.."; 
  19. } else { 
  20. echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<select name=\"CONTACT\" id=\"CONTACT\"><option value=\"ALL\">Select</option>"; 
  21. for($i=0;$i<mysql_num_rows($res);$i++) { 
  22. $row=mysql_fetch_assoc($res); 
  23. echo"<option value=$row[CONTACT]"; 
  24. if($Var==$row[VarietyID]) 
  25. echo " selected"; 
  26. echo ">$row[fname]</option>"; 
  27.  
  28. echo "</select>"; 
  29.  
  30.  
Dec 4 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: anonymous | last post by:
Hi Folks, I have a form with two Dropdown list boxes, which get loaded with data from Database. DropDownList1 gets data from Table1 and DropDownList2 gets data from Table2 Table1 has a...
8
by: Kris Rockwell | last post by:
Hello, I have done the following to bind data to a DropDown box: 1. Drag SQLServer table onto web form to create data connection and data adapter. 2. Generate dataset by right-clicking on...
0
by: Pietje puk | last post by:
Hello, Since im quite new to ASP.NET i wanted to ask you folks what the best way is to create a WebForm for modifying 1 field from a record. The manipulation of this field can be done by using...
1
by: gary | last post by:
In our site we are encountering problems with drop down boxes. We have a dropdown box & the ONChange event of which is fetching some data from a servlet. However when we use history back button ,...
3
by: CSharpguy | last post by:
I'm trying to populate a drop down with dates from a data field in my data base but I want the format like MM/dd/yyyy instead of 1/1/2006 12:00 PM How can I my date to show as 1/1/2006? I'm...
2
by: Peter | last post by:
ASP.NET 2003 In the DataGrid how do I select current cell value in the dropdown box when I click on the edit link, currently when I click on the edit link in the DataGrid the dropdown box...
2
by: William Youngman | last post by:
We are developing an application that presents data to the user in a gridview and we are using the dropdown extender to give the user a SharePoint 2007 type dropdown menu attached to the cells of a...
8
by: Wingot | last post by:
Hey, I have a program I am trying to write using Visual C#, SQL Server 2005/2008, and Visual Studio 2008, and one part of it includes a Schema called Client. Inside this schema, three tables...
5
by: abhi3211 | last post by:
i am using java inside java script page. in that page i want to use two dropdown list. in first dropdown list i am getting data from ms-access database. in second dropdown list i want to get data...
5
by: =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post by:
I have a VS 2008 ASP.NET webform that has a reportview tag on it, accessing an .RLDC report in local report. The columns for the report are essentially: Month Item #1 Item#2 Item#3 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.