Jump to content
php.lv forumi

Topikus un postus izvilkt no foruma


Recommended Posts

Posted

Tātad gribu uztaisīt ka postus un topiku skaitu velk no foruma.

Uzliku šo skriptu:

<?
mysql_connect("localhost","root","aha");
mysql_select_db("f");
$rez=mysql_query("SELECT * FROM ibf_forums");
while($r=mysql_fetch_array($rez)) {
 echo $r['posts'];
echo "<br/>";
echo $r['topics'];
}
?>

Bet man velk kaut kādus nepareizus skaitļus. Forumā ir tikai 2topiki un 1posts, bet viņš man rada Topiki: 20 Posti: 0

Posted

Tur tak nevienā vietā nav saskaitīti ieraksti, tas, kas tev tur ir, tā ir datu izvilkšana, galīgas auzas.

Ierakstu saskaitīšanai lieto mysql_result un kverijā norādi COUNT(*). Sīkāk: http://k4y.lv/raksts/?id=47

Nekādā gadījumā nelieto mysql_num_rows, tas nav optimāls risinājums ierakstu saskaitīšanai.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...