Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 12th, 2004, 06:35 AM
Registered User
 
Join Date: Sep 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting the data out with multiple arguments

I'm quite new to mysql/php so this is probably an easy to solve question for some of you guys but i just can's seem to find it.

I want to extract data from my table using the arguments submitted in a search form.

Is it possible to add these arguments in the WHERE statement that i use to select data from the table?

Of should i work with the result from the query.

For instance: i got a table containg id, coursetype, name, institution.

So if i want to check for all data where coursetype=master and
name LIKE%biology% how should i do this.

Thanx a lot in advance

 
Old September 12th, 2004, 06:45 AM
Registered User
 
Join Date: Sep 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

sorry guys,

Found the answer on this same forum page.

You can use the AND and OR statements! great, Why is this not listed somehwere on php.net or so (or why can't i find it :))

Rogier

 
Old September 12th, 2004, 06:57 AM
Registered User
 
Join Date: Sep 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oh, i'm still stuck with a question:

If in a search forum a field is left blank, How do i prevent it that nothing gets selected.

For instance i have the following line of code
$id=$_GET['id'];
$coursetype=$_GET['coursetype'];
$name=$_GET['name'];

//connect to db
$query = "SELECT * from courses WHERE coursetype= '$courestype' AND name LIKE %$name% ORDER BY name";
$result = mysql_query($query);

NOW if someone leaves the name field blank, nothing gets selected? or does everything? should i fill $name with an asterisk if it is empty?

Plz let me know







Similar Threads
Thread Thread Starter Forum Replies Last Post
Doesn't work properly for multiple file arguments. sbubendorf VBScript 7 September 20th, 2007 08:52 AM
multiple arguments MunishBhatia C# 2 December 8th, 2006 07:34 AM
Passing multiple arguments to function zarikiane XSLT 2 July 18th, 2006 09:35 AM
Problem passing multiple arguments to php script method PHP How-To 0 February 8th, 2006 09:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.