Duplicate Results

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zed420
Forum Commoner
Posts: 32
Joined: Wed Jun 04, 2008 11:24 am

Duplicate Results

Post 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
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Duplicate Results

Post 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! :)
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Duplicate Results

Post 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.
zed420
Forum Commoner
Posts: 32
Joined: Wed Jun 04, 2008 11:24 am

Re: Duplicate Results

Post 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! :)
Post Reply