anonīms Posted March 16, 2008 Report Share Posted March 16, 2008 Esmu izveidojies vēstuļu sistēmu, bet vel arī vēlos, lai pie lietotāja paneļa rādas (2) Vēstules, itkā parādot, ka ir saņemtas 2 nelasītas vēstules. Tabulā vestules ir kollona status, kur 0 - jauna, 1 - lasīta vestules tabula sastāv no: id, kam_id, noka_id, vestules_nosaukums, vestules_teksts, vestules_datums, status īsti nezinu kā veidot, bet varbūt kaut ko līdzīgu šim? $lietotaja_pakape = mysql_query("SELECT lietotaja_pakape, id from lietotaji where lietotajvards = '$_SESSION[lietotajvards]'"); $rows = mysql_fetch_array($lietotaja_pakape); $veestules = mysql_query("SELECT status FROM vestules WHERE status = '0' AND kam_id = '$rows[1]'"); $veestules = mysql_fetch_array($veestules); <a href='http://eip.wc3.lv/vestules'>Vēstules</a><br /> bet kā man saskaitīt cik nelasītās vēstules ir tieši? count(status) ? Link to comment Share on other sites More sharing options...
777 Posted March 16, 2008 Report Share Posted March 16, 2008 $unread = $veestules['status'] = "0"; $msg = count(unserialize($unread)); Link to comment Share on other sites More sharing options...
anonīms Posted March 16, 2008 Author Report Share Posted March 16, 2008 $veestules = mysql_query("SELECT status FROM vestules WHERE status = '0' AND kam_id = '$rows[1]'"); $veestules = mysql_fetch_array($veestules); $unread = $veestules['status'] = "0"; $msg = count(unserialize($unread)); echo"<a href='http://eip.wc3.lv/vestules'>(".$msg.") ".$lang['vestules_vestules']."</a><br />"; Tagad viņš manuprāt saskaita visas nelasītās vēstules, bet kā panākt, ka tikai ielogotā lietotāja? Link to comment Share on other sites More sharing options...
bubu Posted March 16, 2008 Report Share Posted March 16, 2008 =0 vai tomēr ==0? Link to comment Share on other sites More sharing options...
777 Posted March 16, 2008 Report Share Posted March 16, 2008 nu tas jau WHERE `kam_id` = $data['shis_lietotajs']"; Link to comment Share on other sites More sharing options...
anonīms Posted March 16, 2008 Author Report Share Posted March 16, 2008 To kveriju izvadiju SELECT status FROM vestules WHERE status = '0' AND kam_id = '1' tajā viss ir pareizi, bet tāpat uzrāda to (1) Vēstules =0 vai tomēr ==0? šo ar pamēģināju Link to comment Share on other sites More sharing options...
777 Posted March 16, 2008 Report Share Posted March 16, 2008 pirmkart kam_id, nevis 1 , bet $data['user_id'] if($msg > "0") { echo"<a href='http://eip.wc3.lv/vestules'>(".$msg.") ".$lang['vestules_vestules']."</a><br />"; } Link to comment Share on other sites More sharing options...
anonīms Posted March 16, 2008 Author Report Share Posted March 16, 2008 mhm :] šādi apmēram arī pats sapratu $veestules = mysql_query("SELECT count(status) as vestulu_skaits FROM vestules WHERE status = '0' AND kam_id = '$rows[1]'"); $veestules = mysql_fetch_array($veestules); $veestules = $veestules[vestulu_skaits]; if($veestules > 0) { $vestulju_skaits = "(".$veestules.") "; } else { echo ""; } echo"<a href='http://eip.wc3.lv/vestules'>".$vestulju_skaits."".$lang['vestules_vestules']."</a><br />"; Link to comment Share on other sites More sharing options...
777 Posted March 16, 2008 Report Share Posted March 16, 2008 tev fignja sanaak, tu lieto $veestules = arrayam un pec tam tu lieto $veestules = $veestules[vestulu_skaits]; ka tu gribi kaut ko panakt ar vienu un to pashu mainigo divas vietas, viena reize ? Link to comment Share on other sites More sharing options...
eregi Posted March 16, 2008 Report Share Posted March 16, 2008 pats daru kaut kā šitā - function checkpm() { $sql=mysql_query("SELECT * FROM db.table WHERE Kam=".Uid." AND R='0'"); $count=mysql_num_rows($sql); if($count>=1) { return "<font color='red'><b>[".$count."]</b></font>"; } } kur 'R' tur vai ir lasīta, vai nav, ja ir tad 1. Link to comment Share on other sites More sharing options...
Grey_Wolf Posted March 17, 2008 Report Share Posted March 17, 2008 (edited) pats daru kaut kā šitā -$sql=mysql_query("SELECT * FROM db.table WHERE Kam=".Uid." AND R='0'"); $count=mysql_num_rows($sql); Kaa jau anonīms rakstija... labak izmantot : SELECt COUNT(*) AS skaits FROM tabulis WHERE blabla=1 savaadak tiek NOLASITI un PARSUTIITI visi vajadziigie ieraksti .... (parsutiiti gan vinji reali vel netiek ... , bet nokeshoti gan ...) Edited March 17, 2008 by Grey_Wolf Link to comment Share on other sites More sharing options...
Aleksejs Posted March 17, 2008 Report Share Posted March 17, 2008 Manuprāt labāk ir: SELECT COUNT(id) AS skaits FROM tabula WHERE ... Respektīvi COUNT(konkrēts_lauks) nevis COUNT(*). Tiešām nezinu, cik un vai tas ietekmē atrdarbību, atmiņas/indeksu izmantošanu, taču intuitīvi liekās, ka ņemt COUNT(konkrēts_indeksēts_lauks) ir labāk. Link to comment Share on other sites More sharing options...
anonīms Posted March 17, 2008 Author Report Share Posted March 17, 2008 (edited) http://php.lv/f/index.php?s=&showtopic...ost&p=79661 Edited March 17, 2008 by anonīms Link to comment Share on other sites More sharing options...
Recommended Posts