A unique problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
phpfreak
Forum Commoner
Posts: 30
Joined: Fri Mar 21, 2003 10:28 am
Location: New Jersey,USA
Contact:

A unique problem

Post by phpfreak »

dasdf
Last edited by phpfreak on Mon Mar 24, 2003 3:13 pm, edited 1 time in total.
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

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

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."'">

?>
process.php

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");
?>
Post Reply