Youjoomla Support Forums (
-   Anything Goes (
-   -   Help with code please (

treehugger 07-26-2009 02:21 PM

Help with code please
I'm trying to run a report from a MySQL database, based on a number of parameters, which is working fine if you want to return one specific result. I want to return a range of results in which any fields left blank return all results. The report code I have is pretty simple:

PHP Code:

//define strings

//define query
$query "SELECT Date, Incident, Analyst, Assist, Process, Service
FROM data
where Date between ('
$StartDate')  and ('$EndDate')
and Incident LIKE ('
and Process LIKE ('
and Service LIKE ('
and Assist LIKE ('
and Analyst LIKE ('
Order by date"

//run query and error reporting
$result mysql_query($query) or die(mysql_error()); 

there's a bit more to the file but only to add the results to a table and echo them to HTML.

I've worked around the problem by having the HTML form return a wildcard when a field is blank (well, added default values and some overly complicated javascript) so it now works but it's still a bit of a hack and slash job. I just don't know enough PHP to get it to work on the server side code. I did try using an IFNULL statement on a query running between the string definition and the current query but that returned no erorrs and did nothing what-so-ever!

ameenudeen 10-13-2009 09:58 AM

Try to use mysql_fetch_array($result)............ and diplay the results............

All times are GMT -4. The time now is 07:33 PM.

Powered by vBulletin®
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.