Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cookies support

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi, I've never used cookies before and don't know how hard this will be so it maybe abit cheeky of me to ask (if so could you direct me to a manual which may help).

What I was wondering is if someone could edit this script so that the first time it's run it creates a cookie based on the variable $id. If it's run again (the same $id variable) then it gives an error and none of the information in the database is updated.

Thanx

Here's the script -->

$sql = 'UPDATE bands_tbl set nbr_votes = nbr_votes+1 where id = '.$id.' ';
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());

$sql = 'UPDATE bands_tbl set vote_tot = vote_tot+'.$rate.' where id = '.$id.' ';
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());

$sql = 'SELECT id,vote_avg,vote_tot,nbr_votes FROM bands_tbl where id = '.$id.' ';
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
while($data = mysql_fetch_array($req))

$vote_avg = round($data['vote_tot']/$data['nbr_votes'],3);

$sql = 'UPDATE bands_tbl set vote_avg = '.$vote_avg.' where id = '.$id.' ';
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top