Log in

View Full Version : Extra results from MYSQL query in PHP



e1seix
08-29-2007, 08:17 PM
what am i doing wrong here guys?

$startrow=0;
$limit=20;

$qry = mysql_query("SELECT bodycare.*, haircare.* FROM bodycare, haircare WHERE bodycare.avail='true' AND haircare.avail='true' LIMIT $startrow, $limit")or
die(mysql_error());

it should return 6 results between bodycare and haircare. instead it returns 8, - 4 repeats of the first haircare product and 4 of the second haircare product.

why? can you help me fix it?

boogyman
08-29-2007, 08:41 PM
try
SELECT DISTINCT bodycare.* etc etc... it sounds like you have just doubled up.

e1seix
08-29-2007, 08:44 PM
that doesn't remedy the situation. any other ideas guys?

boogyman
08-29-2007, 09:06 PM
WHERE bodycare.avail='true' AND haircare.avail='true'
are you trying to pull in everything that is both both/haircare... are you if not.. possible use

WHERE bodycare.avail='true' OR haircare.avail='true'


if thats not what you are trying to do... please give us more information... because without it, we will not be able to find why you are pulling in extra data that you dont want.

the database will pull in everything that fits the "where" clause requirements

a good start of information to give us is exactly what is being returned.