473,385 Members | 1,546 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,385 software developers and data experts.

Select statement using a second select statement from same input page to gather info

Hey guys I have been checking the forum for a way to populate a second select field depending on the choice made from the first one. Basically i am working on projects and the delays that occur. The first select is project and i am asking user to select it by using

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.           $sql = "SELECT ProjectName
  3.                   FROM   ProjectDetails";
  4.                  "ORDER BY ProjectName";
  5.                 $rs = mysql_query($sql);
  6.                 while($row = mysql_fetch_array($rs))
  7.                 {
  8.                   echo "<option value=\"".$row['ProjectName']."\">";
  9.                 }
  10. ?>
  11.  
then for my second select statement i want it to be populated by using

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.                 $sql = "SELECT Task
  3.                         FROM   Delay
  4.                         WHERE  ProjectName = (the problem) ".
  5.                        "ORDER BY Task";
  6.                 $rs = mysql_query($sql);
  7.                 while($row = mysql_fetch_array($rs))
  8.                 {
  9.                   echo "<option value=\"".$row['Task']."\">";
  10.                 }
  11. ?>
  12.  
I have seen a forum that says to use AJAX (http://bytes.com/forum/thread790663.html) but i dont have enough time to learn this. Is it possible to call the result found from the first select as a variable so i can then use it in the second query? where (the problem) = var1?

Any1 any ideas on this?
Sep 16 '08 #1
3 1702
Markus
6,050 Expert 4TB
If you don't want a page refresh, you're going to have to learn AJAX (It seriously takes no longer than 1 hour to learn.) Otherwise, you will have to submit the dropdown list to the same page (as a form - using GET possibly) and then $_GET the selected projectName and use this in your second WHERE clause to show the related projects.
Sep 16 '08 #2
thanks for the quick reply appreciated. Ill have another look at some tutorials on AJAX if u say it easy to understand. Thanks for clarifying it.
Sep 16 '08 #3
Markus
6,050 Expert 4TB
thanks for the quick reply appreciated. Ill have another look at some tutorials on AJAX if u say it easy to understand. Thanks for clarifying it.
No problem. Once you've had a go, post the code you used (if you have a problem with it) and we'll give you more help!
Sep 16 '08 #4

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

Similar topics

3
by: Steven K | last post by:
Hello, I am using an asp page (upload.asp) to gather information and to upload files to the web server using SoftArtisans SAUpload Tool. In the first page (upload.asp), I have a form for...
17
by: Newbie | last post by:
Dear friends, I am having a hard time understanding how to use a SELECT CASE in ASP. I have used it in VB but never in ASP scripting. Scenerio: I have 2 textboxes on a form that I have to...
0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
6
by: David | last post by:
I am using ADO to run some SQL statements in Access. First, I run query to create a table using SELECT . . . INTO Table A. Then, I run a query to SELECT . . . FROM Table A to get some data and...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
3
by: ven | last post by:
Hello i have two tables in my MS SQL named table1 and table2. In each table i have a column PRICE with my own datatype decimal 14;4 allows nulls.... now i wanna select from one table to second...
2
by: ven | last post by:
Hello i have two tables in my MS SQL named table1 and table2. In each table i have a column PRICE with my own datatype decimal 14;4 allows nulls.... now i wanna select from one table to second...
4
by: Nick Barr | last post by:
Hi, I am trying to gather stats about how many times a resource in our web app is viewed, i.e. just a COUNT. There are potentially millions of resources within the system. I thought of two...
3
by: eholz1 | last post by:
Hello PHP programmers. I had a brilliant idea on one of my pages that selects some data from my mysql database. I first set the page up to display some info and an image, just one item, with a...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.