[PHP-DB] dynamic sql query

2008-07-07 Thread Beth Tucker
Dear Nasreen, You could also do something like this: $query = select * FROM gig g, venue v, genre ge ; if($gig_name) { $wheres[] = g.gigName LIKE '%.$gig_name.%'; } if($gig_date) { $wheres[] = g.gig_date LIKE '%.$sdate.%'; } if(is_array($wheres)) { $wheres = implode( OR , $wheres);

Re: [PHP-DB] dynamic sql

2002-01-25 Thread Miles Thompson
Michael, Yes. Just go ahead, and echo $sql to see what you have. You can build quite complex queries this way, dependent upon input from picklists, checkboxes, etc., adding and dropping conditions according to whether or not they have been selected/set. So why not $sql = UPDATE $fieldlist

[PHP-DB] dynamic sql

2002-01-24 Thread Michael K. Dolan Jr.
Is it possible to do a sort of dynamic sql. For instance, if I have a form with a bunch of field/data variables and I send them to a php processor, can I just create a loop to have it update all the fields without having to specify each field. In scratch code, I guess I'm looking for something

Re: [PHP-DB] dynamic sql

2002-01-24 Thread Richard Crawford
Have you tried it? I've done this sort of thing before, and it works just fine. By the time the query string is executed, the variables have been interpreted. So, if $colName = id, and $id = 12, then your query variable looks something like select * from myTable where $colName = $id. By

[PHP-DB] dynamic sql

2002-01-24 Thread Michael K. Dolan Jr.
Rich, thanks. I got the dynamic sql to work (i had a syntax problem), now my problem is what's the most efficient way to loop it through all the form fields that are passed to the processor? This is my current sql statement which handles 1 field: $sql_update = UPDATE md_users SET .$formName. =

RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-09 Thread Mats Remman
/Mysql DBA Coretrek, Norway +47 51978597 / +47 916 23566 -Original Message- From: Matthew Loff [mailto:[EMAIL PROTECTED]] Sent: Monday, July 09, 2001 2:20 AM To: 'Ben Bleything'; 'Mark Gordon'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Dynamic SQL + result resource error Ha ha... I

RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-09 Thread Michael Rudel
___ -Original Message- From: Mark Gordon [mailto:[EMAIL PROTECTED]] Sent: Monday, July 09, 2001 1:54 AM To: [EMAIL PROTECTED] Subject: [PHP-DB] Dynamic SQL + result resource error Why is this code generating an error when it outputs a valid SQL

[PHP-DB] Dynamic SQL + result resource error

2001-07-08 Thread Mark Gordon
Why is this code generating an error when it outputs a valid SQL statement? (there are no parse errors) //$find is text box input $wordsarray = explode( ,$find); $sql = SELECT bandname FROM bands WHERE (bandname LIKE ; $i = 0; while ($i count($wordsarray)) { $word =

RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-08 Thread Matthew Loff
); $i++; } print $sqlhr; $queryResult = mysql_query($sql); while ($myrow=mysql_fetch_row($queryResult)) { print $myrow[0],p; } -Original Message- From: Mark Gordon [mailto:[EMAIL PROTECTED]] Sent: Sunday, July 08, 2001 7:54 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Dynamic SQL

RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-08 Thread Ben Bleything
Sure he is. Right here: $queryResult = mysql_query($sql); what exact error is occurring? -Original Message- From: Matthew Loff [mailto:[EMAIL PROTECTED]] Sent: Sunday, July 08, 2001 5:00 PM To: 'Mark Gordon'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Dynamic SQL + result resource error

RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-08 Thread Matthew Loff
The code you're referencing is my modification of his original post. :) -Original Message- From: Ben Bleything [mailto:[EMAIL PROTECTED]] Sent: Sunday, July 08, 2001 8:04 PM To: 'Matthew Loff'; 'Mark Gordon'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Dynamic SQL + result resource error

RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-08 Thread Ben Bleything
: [PHP-DB] Dynamic SQL + result resource error The code you're referencing is my modification of his original post. :) -Original Message- From: Ben Bleything [mailto:[EMAIL PROTECTED]] Sent: Sunday, July 08, 2001 8:04 PM To: 'Matthew Loff'; 'Mark Gordon'; [EMAIL PROTECTED] Subject: RE

RE: [PHP-DB] Dynamic SQL + result resource error

2001-07-08 Thread Matthew Loff
To: 'Matthew Loff'; 'Mark Gordon'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] Dynamic SQL + result resource error Guess I'm just a big dumbass then, aren't I =P Oops. I suppose that would cause it to fail then, wouldn't it? = Ben -Original Message- From: Matthew Loff [mailto:[EMAIL