voting problem
Posted: Thu Dec 28, 2006 7:45 pm
this code work find to update a record that already exist, but the insert query doesn't work at all..
Code: Select all
<?php
$a_t_id=$artist['artist_id'];
$getcounter=mysql_query("SELECT counter FROM tra_music_top10 WHERE artist_id='$a_t_id'")or die(mysql_error());
$count=mysql_fetch_array($getcounter);
if(!$count['counter']){
echo 0;
}else{
$i=$count['counter'];
echo $i;
}
if($_POST['Submit']){
$voted=($i+1);
$update=mysql_query("UPDATE tra_music_top10 SET counter='$voted' WHERE artist_id='$a_t_id'")or die(mysql_error());
if(!$update){
$newrecord=mysql_query("INSERT into tra_music_top10(artist_id,counter)VALUES('$a_t_id','1')")or die(mysql_error());
}
}
?>