User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,713 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,421 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 3444 | Replies: 1
Reply
Join Date: Feb 2006
Posts: 1
Reputation: markmuir_8 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
markmuir_8 markmuir_8 is offline Offline
Newbie Poster

Multiple queries within one php file

  #1  
Feb 8th, 2006
Hi guys, i'm having a major problem with producing queries using PHP. By the way, not that good at trying to explain problem!!

I want to be able to run queries within a PHP form without having to input values into every fields(meaning searching the database for field1, fields2, field4 & field5 whilst field 3, field 6 & field 7 are empty). There are 7 fields. An example of what I'm looking for is:-

If a user wants to know how many males, in Year 2 walk to school and thinks that the roads are busy.

The names of the fields are:- gender, yeargroup, walkcycle, bustrain, crossbusyroads, school, security.

P.s Using MySQL database

Any help at all would be greatly appreciated.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2005
Location: Colorado
Posts: 50
Reputation: barnamos is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
barnamos's Avatar
barnamos barnamos is offline Offline
Junior Poster in Training

Re: Multiple queries within one php file

  #2  
May 8th, 2006
Seems like you could build your query according to what it entered. I take it you are having trouble because field 7 might be blank and you don't want to search for a blank field 7, you want to ignore field 7?

So just do a:
if ($_POST["gender"]) $qry.="gender='". $_POST["gender"]."',";
for each field.

Note the .= which keeps adding each part to the query.

Then trim the last comma off and use $qry as your query.

Good luck
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

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

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:11 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC