KintaRo Posted June 10, 2011 Share Posted June 10, 2011 arkadaşlar PHP ile ilgili yardıma ihtiyacım var. Şimdi olay şu. [b]tablo: users[/b] alanlar: [b]id - user - count - date[/b] [b]$username[/b] foreach döngüsündeki gelen kullanıcı adı. şimdi istediğim kod; $username karşlığındaki kullanıcı tabloda bulacak, eğer o gün için ona ait bir kayıt varsa count alanını +1 yapacak, eğer ona ait bir kayıt yoksa id - $username - 1 - tarih şeklinde tabloya satir ekleyecek. Görüntü şu şekilde olacak [quote]id - user - count - date --- ------ ------- ------- 1 | kintaro | 5 | 09.06.2011 2 | kintaro | 1 | 10.06.2011[/quote] Kısaca hangi kullanıcı siteye hangi günde kaç kere giriş yapmış onu öğrenmek istiyorum. Bunu AMS ve SQLite'da yapabilirim ama PHP'ye tam vakıf değilim. Yardımcı olursanız sevinirim. Quote Link to comment Share on other sites More sharing options...
galetis Posted June 10, 2011 Share Posted June 10, 2011 Yettim abi [php] <?php $tarih = date("d/m/y"); $query = mysql_query("select * from users where user='$username' and date=$tarih"); if(mysql_num_rows($query) > 0){ $al = mysql_fetch_array($query); $arttir = $al[2] + 1; $id = $al[0]; mysql_query("update users set count=$arttir where id=$id"); } else { mysql_query("insert into users (user, count, date) values ('kintaro', 1, $tarih)"); } ?> [/php] Quote Link to comment Share on other sites More sharing options...
KintaRo Posted June 10, 2011 Author Share Posted June 10, 2011 (edited) olm msnde ariyom seni dünden beri yoksun, neyse halletmişsin sağolasın Edit: bu adama iyi bakın SQL canavarı bu kaçırmayın derim yapışın yakasına, bana SQLi galetis öğretti, buna değinmeden geçemeyeceğim Edited June 10, 2011 by KintaRo Quote Link to comment Share on other sites More sharing options...
galetis Posted June 10, 2011 Share Posted June 10, 2011 Abi iş güç bi girip bi çıkıyom valla. Sen biliyodun zaten sqli ben sadece biraz yardım ettim 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.
Note: Your post will require moderator approval before it will be visible.