Hello there! Welcome to Youjoomla Support Forums

We are Web Development Company specializing in Joomla Templates , Joomla Extensions and WordPress Themes development . You are not able to see some forum threads due to your memberhip level. To unlock all forums and special customer support please take few moments to signup . If you are just searching for free joomla templates , or free joomla extension support simply head to our Free Joomla Support forums and open a new thread. Our moderators will help you as soon as possible. To spead up the response time please take few seconds and go over forum rules

Have fun!

Help with code please

07-26-2009, 02:21 PM
# 1 (permalink)
treehugger
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
$StartDate=$_GET['requiredStartDate'];
$EndDate=$_GET['requiredEndDate'];
$Analyst=$_GET['Analyst'];
$Assist=$_GET['Assist'];
$Incident=$_GET['Incident'];
$Process=$_GET['Process'];
$Service=$_GET['Service'];

//define query
$query "SELECT Date, Incident, Analyst, Assist, Process, Service
FROM data
where Date between ('
$StartDate')  and ('$EndDate')
and Incident LIKE ('
$Incident')
and Process LIKE ('
$Process')
and Service LIKE ('
$Service')
and Assist LIKE ('
$Assist')
and Analyst LIKE ('
$Analyst')
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!
10-13-2009, 09:58 AM
# 2 (permalink)
ameenudeen
Try to use mysql_fetch_array($result)............ and diplay the results............
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Members Login

Username
Password