Jump to content

Recommended Posts

I have 2 image button which allow users to change the status in or out:

 

1.jpg

 

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?

Link to comment
https://forums.phpfreaks.com/topic/128475-image-button/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/128475-image-button/#findComment-665836
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/128475-image-button/#findComment-665837
Share on other sites

<?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: ?");
  }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/128475-image-button/#findComment-666383
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.