Slammer Posted December 28, 2006 Report Posted December 28, 2006 $sql = "SELECT max(`id`) FROM `statistic`"; $sql = mysql_query($sql); while($row = mysql_fetch_array($sql)){ echo $row["id"]; } Kapē neuzrāda manējo lielāko id vērtību? Paldies.
andrisp Posted December 28, 2006 Report Posted December 28, 2006 Kverijs ir ok, bet pie echo id indeks ir neeksistējošs. Uztaisi print_r($row); Pamēģini: SELECT max(`id`) as max_id FROM `statistic` PS. Kas tā par modi rezultsetus, kur būs tikai viena rinda, apstaigāt ar while ?
Slammer Posted December 28, 2006 Author Report Posted December 28, 2006 Paldies $sql = "SELECT max(`id`) as max_id FROM `statistic`"; $sql = mysql_query($sql); $row = mysql_fetch_array($sql); echo $row["max_id"];
bubu Posted December 28, 2006 Report Posted December 28, 2006 Neaizmirstam arī par mysql_fetch_row: $sql = "SELECT max(id) FROM statistic"; $row = mysql_fetch_row(mysql_query($sql)); echo $row[0];
Recommended Posts