candice Posted October 15, 2008 Share Posted October 15, 2008 I have 2 image button which allow users to change the status in or out: Meaning that when user click on the red icon, the status would automatically change to in and when click on the green icon, it will change to out. I did some codings, but the value doesn't seem to be passing in. <input type="image" src="images/icons/in.jpg" value="In" alt="submit"/> can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/128475-image-button/ Share on other sites More sharing options...
ram4nd Posted October 15, 2008 Share Posted October 15, 2008 first you have to split up the image, but i don't get it what do you exactly want to do. I mean where do you want to use it and where do you want to remember the status. Quote Link to comment https://forums.phpfreaks.com/topic/128475-image-button/#findComment-665831 Share on other sites More sharing options...
candice Posted October 15, 2008 Author Share Posted October 15, 2008 Thanks for replying. The button is actually split up,meaning its two different pictures. What i want is something like, when the user clicks on one button, the value of the button would then be captured and then the form would then be submitted, updating the status in the database. it works something like creating a radio button, selecting one of the radio buttons and then pressing the update button to change the status, just that in this case, i do not want the update button, just clicking the image itself and then updating the status Quote Link to comment https://forums.phpfreaks.com/topic/128475-image-button/#findComment-665836 Share on other sites More sharing options...
Lamez Posted October 15, 2008 Share Posted October 15, 2008 here is an idea. create a new php page, set the images to links, and make the links like so: page.php?stat=in or out. Then create a if statement, state weather the get variable is in or out, after you stated it has been set, if the variable is in, create a query to update the database, same with out, redirect back to the previous page. Now create another if statement, ask weather in the database the user is in, echo out green in image. Same for out, I can code this for you, but it will have to wait till tomorrow. Quote Link to comment https://forums.phpfreaks.com/topic/128475-image-button/#findComment-665837 Share on other sites More sharing options...
candice Posted October 15, 2008 Author Share Posted October 15, 2008 Thanks.. we will also try it.. but could u help us to code that part to make sure that we are on the right track?? Thanks a milion. Quote Link to comment https://forums.phpfreaks.com/topic/128475-image-button/#findComment-665838 Share on other sites More sharing options...
Lamez Posted October 15, 2008 Share Posted October 15, 2008 I sure can, will only take about ten minuets, but nothing bad can come out of practice ! Quote Link to comment https://forums.phpfreaks.com/topic/128475-image-button/#findComment-665839 Share on other sites More sharing options...
PFMaBiSmAd Posted October 15, 2008 Share Posted October 15, 2008 To get the value from an image being used as a submit button, read this - http://us.php.net/manual/en/faq.html.php#faq.html.form-image Quote Link to comment https://forums.phpfreaks.com/topic/128475-image-button/#findComment-665942 Share on other sites More sharing options...
Lamez Posted October 15, 2008 Share Posted October 15, 2008 <?php ob_start(); $img_path = "img"; if(empty($_GET['s'])){ //$q = mysql_query("SELECT * FROM `table_name`"); //$r = mysql_fetch_array($q); $o_stat = $r['stat']; if($o_stat == (1)){ echo '<a href="?s=in"><img src="'.$img_path.'/in_green.bmp"></a> <a href="?s=out"><img src="'.$img_path.'/out_red.bmp"></a>'; } if($o_stat == (2)){ echo '<a href="?s=in"><img src="'.$img_path.'/in_red.bmp"></a> <a href="?s=out"><img src="'.$img_path.'/out_green.bmp"></a>'; } echo $o_stat; }else{ if($_GET['s'] == ("in")){ //mysql_query("UPDATE `table_name` WHERE `stat` = '1'"); header("Location: ?"); } if($_GET['s'] == ("out")){ //mysql_query("UPDATE `table_name` WHERE `stat` = '2'"); header("Location: ?"); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/128475-image-button/#findComment-666383 Share on other sites More sharing options...
candice Posted October 20, 2008 Author Share Posted October 20, 2008 Hi, Thanks for the help!! I'll go and give it a try. Quote Link to comment https://forums.phpfreaks.com/topic/128475-image-button/#findComment-669674 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.