Hallo,
Ich muss sehr oft abfragen, wie viele Zeilen in einer Tabelle vorhanden sind.
Im moment mache ich das so:
  
$sql="SELECT id,userid,title,content FROM pm WHERE myid='".$MyID."';";  
$result=mysql_query($sql) OR DIE (mysql_error());  
$count=mysql_num_rows($result);  
  
if ($count>0)  
while ($row=mysql_fetch_assoc($result))  
{  
  ...  
}  
Nun habe ich aber gelesen, dass das sehr langsam ist. Und man sollte das mit dem Befehl COUNT machen:
  
$sql="SELECT COUNT(id) FROM pm WHERE myid='".$MyID."';";  
$result=mysql_query($sql) OR DIE (mysql_error());  
$count=mysql_fetch_array($result);  
$count=$count[0];  
  
if ($count>0)  
{  
  $sql="SELECT id,userid,title,content FROM pm WHERE myid='".$MyID."';";  
  $result=mysql_query($sql) OR DIE (mysql_error());  
  
  while ($row=mysql_fetch_assoc($result))  
  {  
    ...  
  }  
};  
Was stimmt nun? Was ist besser?
 nicht angemeldet
 nicht angemeldet