Re: Is there an easier way to do this

From: Date: Mon, 08 Oct 2001 15:53:20 +0000
Subject: Re: Is there an easier way to do this
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-13115@lists.php.net to get a copy of this message
try a single query $update=mysql_query("update mp3s set votes=votes+1 where id=".$vote); hope this helps, Steve "Claymen" <claymencyberdudecom@pb1.pair.com> wrote in message news:Xns9134E63EB4B91Claymen@216.92.131.4... > Im writing a voting system for mp3s at lans > I wanna know if there is a simpler way to do the following > > $songvotes = mysql_query("SELECT votes FROM mp3s Where ID=".$vote); > $row = mysql_fetch_array($songvotes); > $songvotes = $row["votes"]; > mysql_query("UPDATE mp3s SET votes = ".($songvotes+1)." WHERE ID=".$vote); > } > > what its doing is adding one to an mp3s votes when someone clicks a link ofr > submits a form to the script with the id of the song to give it a vote > > where $vote is the id for the mp3 which is gotten via a query or posted from > a form > > the mp3s table has 3 fields, the songname in text the id which is an > autoincremented integer and vote which is the number ov votes and is an > integer; > > just the way i had to retreive the number of votes first is there a simpler > way to do that cause my way seems way to long and tedious > > Claymen (claymen(at)cyberdude(dot)com)

« previous php.db (#13115) next »