anonīms Posted April 15, 2009 Report Share Posted April 15, 2009 (edited) t1 - turniri `id``nosaukums` `turnira_statuss` t2 - turniru_dalibnieki `id``lietotaja_id` `turnira_id` `komandas_id` Ideja ir tāda, ka nepieciešams izvilkt count() statistikai Cik turnīros piedalās. (Saskaitīt cik turnīros piedalās lietotājs, kas pašlaik ir ielogojies). Mēģināju kaut ko "skrūvēt" kopā, bet šķiet, ka nekas nav izdevies. $kilz0rkje = "SELECT count(bliezam_turniri.id) as tp_skaits FROM bliezam_turniru_dalibnieki, bliezam_turniri WHERE bliezam_turniri.turnira_statuss = '2' OR bliezam_turniri.turnira_statuss = '3' AND bliezam_turniru_dalibnieki.lietotaja_id = '".$rows['id']."' "; $tpps = mysql_query($kilz0rkje) or die(mysql_error()); $tpps = mysql_fetch_array($tpps); echo $tpps['ap_skaits']; Kur varētu būt vaina? Edit: Mans izvadītais skaitlis ir 390, kas ne tuvu nav patiess. Edited April 15, 2009 by anonīms Quote Link to comment Share on other sites More sharing options...
codez Posted April 15, 2009 Report Share Posted April 15, 2009 jāpieliek vēl AND bliezam_turniru_dalibnieki.turnira_id=bliezam_turniri.id Quote Link to comment Share on other sites More sharing options...
anonīms Posted April 15, 2009 Author Report Share Posted April 15, 2009 Tāpat izvadīts tiek pārmērīgi liels skaitlis $kilz0rkje = "SELECT count(bliezam_turniri.id) as tp_skaits FROM bliezam_turniri, bliezam_turniru_dalibnieki WHERE bliezam_turniri.turnira_statuss = '2' OR bliezam_turniri.turnira_statuss = '3' AND bliezam_turniru_dalibnieki.lietotaja_id = '".$rows['id']."' AND bliezam_turniru_dalibnieki.turnira_id=bliezam_turniri.id "; Quote Link to comment Share on other sites More sharing options...
codez Posted April 15, 2009 Report Share Posted April 15, 2009 SELECT count(id) FROM bliezam_turniru_dalibnieki WHERE lietotaja_id=2; Quote Link to comment Share on other sites More sharing options...
anonīms Posted April 15, 2009 Author Report Share Posted April 15, 2009 Ja pirms tam skaitlis bija 360, tad tagad rāda tikai 6. Quote Link to comment Share on other sites More sharing options...
anonīms Posted April 15, 2009 Author Report Share Posted April 15, 2009 (edited) Tāk. $kilz0rkje = "SELECT count(bliezam_turniri.id) as tp_skaits FROM bliezam_turniri WHERE bliezam_turniri.turnira_statuss = '2' OR bliezam_turniri.turnira_statuss = '3' "; skaitlis = 2 bet ja pieliek tā, tad ir 390 $kilz0rkje = "SELECT count(bliezam_turniri.id) as tp_skaits FROM bliezam_turniri, bliezam_turniru_dalibnieki WHERE bliezam_turniri.turnira_statuss = '2' OR bliezam_turniri.turnira_statuss = '3' "; Edited April 15, 2009 by anonīms Quote Link to comment Share on other sites More sharing options...
marcis Posted April 15, 2009 Report Share Posted April 15, 2009 SELECT COUNT(bliezam_turniri.id) AS tp_skaits FROM `bliezam_turniri`, `bliezam_turniru_dalibnieki` WHERE bliezam_turniri.turnira_statuss IN (2,3) AND bliezam_turniru_dalibnieki.lietotaja_id=$id AND bliezam_turniru_dalibnieki.turnira_id=bliezam_turniri.id Quote Link to comment Share on other sites More sharing options...
anonīms Posted April 15, 2009 Author Report Share Posted April 15, 2009 aha. Viss iet. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.