|
Posted by Wendy Hoovens on 10/11/57 11:32
Erwin Moller schreef:
> Wendy Hoovens wrote:
>
>
> Hi Wendy,
>
> I putted a few suggestion between your lines.
>
>
<snip>
> Also, if you do it like above you will never see where you made the mistake.
> Simply change to this:
> $SQL = "SELECT location, COUNT(type) FROM bib WHERE ";
> $SQL.= "((type='magazine') AND ";
> $SQL.= "(datum>='$start' AND ";
> $SQL.= "(datum<='$eind')) GROUP BY location";
>
> Before executing, just echo your $SQL:
> echo $SQL;
>
> Simple as that, now you see the SQL you are going to execute and can see the
> errors right away, like the fact you mixed the words location and locatie.
>
> Copy the SQL and try to execute it straight away against the database, using
> a commandline tool or something. (Depends on your database).
> ALWAYS just check the SQL when you are uncertain.
>
> Then try: mysql_query($SQL);
>
>
>
>>echo "$result";
>
>
> That doesn't make sense.
> The $result contains a complex structured array, called a 'resource', that
> might contain all the rows if the query was succesfull, besides possible
> other stuff. You cannot just echo it.
>
> Try this instead:
> <pre>
> <? print_r($result); ?>
> </pre>
>
> Now you get a dump of the $result.
>
> If you want to use the $result to display things that your query returned,
> loop over the resultset.
> Read on here on how and what and many examples too:
> http://nl3.php.net/manual/en/function.mysql-query.php
Thank you for your feedback ERwin! I've been reading about the
mysql_fetch possibilities but it seems I'm still missing out on
somethinbg. I know that without the mysql_fetch I can only echo a
Resource id #x But how does it translate correctly to the actual valuess?
<?
$SQL = "SELECT loaction, COUNT(type) FROM bib WHERE ";
$SQL.= "type='magazine' AND ";
$SQL.= "datum='$start' AND ";
$SQL.= "datum<='$eind' GROUP BY location";
echo $SQL;
$result=mysql_query($SQL);
while ($row = mysql_fetch_assoc($result)) {
echo $row['location'];
echo $row['type'];
}
?>
Kind regards,
Wendy
Navigation:
[Reply to this message]
|