Jump to content

Php>Sql Sorgulama


Recommended Posts

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.
Link to comment
Share on other sites

Yettim abi :lol:

[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]

Link to comment
Share on other sites

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 by KintaRo
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...