This is a discussion on Newbie search within the PHP Language forums, part of the PHP Programming Forums category; Hi there I'm interested in doing a simple search with mysql and php.. Right now it finds both of ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi there I'm interested in doing a simple search with mysql and php.. Right
now it finds both of the fields: SELECT * FROM itltest WHERE jobnum='$jobnum' AND custID='$custID What I want it to do is to find all custID within the jobnum if the jobnum is left blank in the field.. Any help would be appreciated! |
|
|||
|
phatnugs420@comcast.net wrote:
> Hi there I'm interested in doing a simple search with mysql and > php.. > Right now it finds both of the fields: > > SELECT * FROM itltest WHERE jobnum='$jobnum' AND custID='$custID > > What I want it to do is to find all custID within the jobnum if the > jobnum is left blank in the field.. Any help would be appreciated! I'm not exactly certain if I understood your question correctly, but do you mean something like: <? $query = "SELECT * FROM itltest WHERE jobnum='$jobnum'"; if ( isset( $custID ) && ( $custID === "" ) ) { $query .= " AND custID='$custID'"; } // ...and off we go to execute query... ?> -- Markku Uttula |