A unique problem
Moderator: General Moderators
- daven
- Forum Contributor
- Posts: 332
- Joined: Tue Dec 17, 2002 1:29 pm
- Location: Gaithersburg, MD
- Contact:
You need to bounce between pages (or just submit to the same page). Either way, you need to load a page so the php can process, since client-side stuff is handled by javascript. example follows
form.php
process.php
form.php
Code: Select all
<?php
$state=$_GET['state'];
if($state=="on"){$src="on_button_src";}
else{$src="Off_button_src";}
echo "<img name="button" src="".$src."" onclick="javascript:self.location='process.php?id=".$id."'">
?>Code: Select all
<?php
$id=$_GET['id'];
$sql="UPDATE table SET row='on' WHERE id=".$id;
mysql_query($sql,$db_conn);
header("Location: form.php?state=off");
?>