Mikus Posted June 28, 2006 Report Share Posted June 28, 2006 Nu lieta taada kad es pats nesu diesko zinosh programetajs(ja mani par tadu vispar var saukt) bet nu nedaudz es zinu... Es velejos uzzinat piemeram ja es esmu datubazest tabula 'poll' ierakstijis 4 rindinas un velejos uzzinat ka butu iespejams uz lapa.php ievietot skaitu cik rindinas ir ieakstitas tabula? ludzu kad iepostojiet kadu funkciju un ka vinju pareizi lietot... Link to comment Share on other sites More sharing options...
Klez Posted June 28, 2006 Report Share Posted June 28, 2006 skaties manuaalii, mysql funkcijas http://lv.php.net/manual/en/ref.mysql.php tur ir rakstiits kaa pareizi lietot. saac ar mysql_query tad mysql_fetch_row vai mysql_fetch_array $all = "select `lauks` from `tabula`"; echo mysq_num_rows($all); //te tev buuus , cik ira ieraksti Link to comment Share on other sites More sharing options...
bubu Posted June 28, 2006 Report Share Posted June 28, 2006 Klez: nelabi, nu nelabi tu raksti. (pie tam ar kļūdu - kur mysql_query?) $res = mysql_query("SELECT COUNT(lauks) FROM tabula"); list($count) = mysql_fetch_row($res); echo $count; //te tev buuus , cik ira ieraksti Link to comment Share on other sites More sharing options...
Grey_Wolf Posted June 29, 2006 Report Share Posted June 29, 2006 (edited) Var arii shaadi: $res = mysql_query("SELECT COUNT(*) AS skaits FROM tabula"); $row=mysql_fetch_array($res); echo $row['skaits']; // skaits buus sheit edit: pieziime skaitu nosaka SQL f-ja COUNT() ..... ar AS var pieskjirt dotajam rezultaatam nosaukumu ... sajaa gadijumaa "skaits" Edited June 29, 2006 by Grey_Wolf Link to comment Share on other sites More sharing options...
slicer Posted June 29, 2006 Report Share Posted June 29, 2006 Vēl neliela piebilde, pirms ķeries pie skaitīšanas. Count funkcija neskaitīs ierakstu, ja norādītajā laukā būs NULL. Piemēram tu raksti: ... count(phone) ... un phone tev varētu būt tukšs, tad tos ierakstus, kur phone būs tukšs, count nesaskaitīs. Tādēļ labāk ir vienmēr lietot count(*) vai vismaz skaitīt pēc atslēgas lauka, ja tāds ir - pretējā gadījumā būs gļuki. Link to comment Share on other sites More sharing options...
Mikus Posted June 29, 2006 Author Report Share Posted June 29, 2006 ok liels paldies visiem :D Link to comment Share on other sites More sharing options...
bubu Posted June 29, 2006 Report Share Posted June 29, 2006 Lai nerastos problēma ar NULL laukiem prosta var skaitīt primārās atslēgas lauku: COUNT(id) Link to comment Share on other sites More sharing options...
Recommended Posts