Page 1 of 1
Duplicate Results
Posted: Wed Nov 26, 2008 11:25 am
by zed420
Hi All
Can some please tell me what is wrong with this query it’s bringing out the Duplicate results according to $pagesize . As it is now it’s bringing out same result three times. Why??? I have inserted the query into phpMyAdmin its working fine bringing out one result. Some help will be greatly appreciated. Thanks
Code: Select all
$pagesize = 3;
$recordstart = (isset($_GET['recordstart'])) ? $_GET['recordstart'] : 0;
$query1 = "SELECT * FROM job_tb,user
WHERE job_tb.status = 'No' OR
job_tb.cust_address = 'Cancel' AND
user_id = id
ORDER BY job_id DESC LIMIT $recordstart, $pagesize";
$result1 = mysql_query($query1)or die(mysql_error());
Thank in advance
Zed
Re: Duplicate Results
Posted: Wed Nov 26, 2008 12:57 pm
by JAB Creations
Hi Zed,
I try to avoid using
SELECT * unless I absolutely am sure I want to support a dynamic number of things to reference in the future...plus when posting because I know one of our fellow forum members prefers it.
I recommend saving the query but not executing it and then using a print_r function to echo the output...run it through MySQL (I use phpMyAdmin) and tinker with the query from there. Really sometimes you just have to keep messing with it...what happens if I change...remove...add...etc.
Plus I know OR and AND in MySQL have different functions...are you absolutely sure you are using them together in the desired context? I always sort of thought of how OR is used as more of an AND method but I'm hardly a pro with MySQL. It's just what sort of stands out to me. Try switching that around in example and good luck!

Re: Duplicate Results
Posted: Wed Nov 26, 2008 2:32 pm
by califdon
What do you mean by "duplicate results"? Do you mean that it is returning 3 rows with the same data? Also, you haven't shown any code for fetching rows from the results array. Hopefully you are doing that. Finally, default the recordstart to 1, not 0.
Re: Duplicate Results
Posted: Tue Dec 02, 2008 12:01 pm
by zed420
Thanks blue
Zed
JAB Creations wrote:Hi Zed,
I try to avoid using
SELECT * unless I absolutely am sure I want to support a dynamic number of things to reference in the future...plus when posting because I know one of our fellow forum members prefers it.
I recommend saving the query but not executing it and then using a print_r function to echo the output...run it through MySQL (I use phpMyAdmin) and tinker with the query from there. Really sometimes you just have to keep messing with it...what happens if I change...remove...add...etc.
Plus I know OR and AND in MySQL have different functions...are you absolutely sure you are using them together in the desired context? I always sort of thought of how OR is used as more of an AND method but I'm hardly a pro with MySQL. It's just what sort of stands out to me. Try switching that around in example and good luck!
