phpbar.de logo

Mailinglisten-Archive

Re: [php] Nochmal INSERT/REPLACE
Archiv Mailingliste php_(at)_infosoc.uni-koeln.de

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [php] Nochmal INSERT/REPLACE



Am 16 Jun 99, schrieb Kronsbein, Mark zu "[php] Nochmal INSERT/REPLACE":

> [schnipp]
> $query = mysql_fetch_row(mysql_query("select * from $userstable where(url
> = '$url')")); if ($query == false){ $hits = "1"; $query2 = "INSERT INTO
> $userstable (url,hits) VALUES('$url','$hits')"; } else { $hitquery =
> "select hits from $userstable where(url = '$url')"; $hits2 =
> mysql_query($hitquery);
> $hits = $hits2 + 1;
> $query2 = "replace into $userstable (hits) VALUES('$hits') where (url =
> '$url')"; } MYSQL_QUERY($query2); [schnapp]

Das sollte auch einfacher gehen (ungetestet):

if (!mysql_query("insert into $userstable (url,hits) values 
('$url',0)")) {
  mysql_query("update $userstable set hits=hits+1 where url='$url'");
}

Gruß, Reiner

-- 
NETZKONZEPTE - http://kukulies.de

Home | Main Index | Thread Index

php::bar PHP Wiki   -   Listenarchive