Jack <[email protected]> wrote:
>Hello All,
>
>
>
>I have this string defined for my query and it shows the different
>types of
>categories fine, but when I change a.categoryid = c.categoryid to
>a.categoryid = 1 which is only one of the categories
>
>It shows me the same record twice.
>
>
>
>$query = "select a.startdate, a.articleid, c.name, a.title, a.intro,
>a.datecreated from articles as a, categories as c where (a.startdate =
>-1 or
>a.startdate <= {$now}) and (a.enddate = -1 or a.enddate >= {$now}) and
>a.categoryid = c.categoryid order by a.startdate DESC";
>
>
>
>
>
> while ( $row = mysql_fetch_array($res) ) {
>
> $tpldata['articles'][] = array(
>
> 'title' => $row['title'],
>
> 'intro' => makeLinks($row['intro']),
>
> 'id' => $row['articleid'],
>
> 'categoryname' => $row['name'],
>
> 'created' => date('n/j/Y',
>$row['datecreated'])
>
> );
>
> //echo $row['datecreated'];
>
> }
>
>
>
>Any Ideas???
>
>
>
>
>
>Thanks!
>
>
How many entries in total are in your categories table? You're joining the
table but not putting any kind of constraint on the joined tables, so its doing
a join on all the rows. You can either add an extra clause on the join, leave
the original join and limit with a where clause, or use a group by on that
field.
Thanks,
Ash
http://ashleysheridan.co.uk
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php