"Ole Madsen" <olem@post6.tele.dk> skrev i en meddelelse
news:9h4vl2$6h8$1@news.inet.tele.dk...
> > select count(*) from tabelnavn
>
> Hvad skal jeg skrive i $articles for at få resultatet?
>
> <?
> $db_name = "olemadsen";
> $table_name = "headers";
>
> $connection = @mysql_connect("localhost")
> or die("Couldn't connect.");
>
> $db = @mysql_select_db($db_name, $connection) or die("Could'nt select
> database");
> $sql = "select count(*) from $table_name";
>
> $result = @mysql_query($sql, $connection) or die("Could'nt execute
query");
>
> while ($row = mysql_fetch_array($result)) {
> $id = $row['id'];
> $authid = $row['authid'];
> $book = $row['book'];
> $articles .= " <BR>";
> }
> ;
> ?>
>
> <HTML>
> <HEAD>
> <TITLE> type_Document_Title_here </TITLE>
>
> </HEAD>
> <BODY>
> <? echo "$articles" ?>
¨
Det skal du ikke bruge til noget som helst!
For at tælle antal artikler skal du ikke bruge while-løkker m.v.
Prøv med dette:
$result = mysql_query("SELECT COUNT(*) FROM artikler");
$antal_artikler = mysql_result($result,0);
--
Mvh. Jonas Delfs,
http://delfs.dk
e72bd3e51a7937c87d28b85d677a97b2