0

//Following code to generate 25 Button with unique name for each button
// 25 buttons contains value from 1 to 25
// like btn1='1',btn2='2' ... btn25='25'

 <?php 
                  $j=0;
                        for($i=1;$i<=25;$i++)
                        {
                                $j++;
                                    ?> 
                                    <td><input type='button' id='btn' name="btn<?php echo $i;?>" value='<?php echo $i;?>' onclick="cnt(btn<?php echo $i;?>);" ></td>
                                    <?php                               
                                    if($j==5)
                                    {
                                        echo "</tr>";
                                        echo "<tr>";
                                        $j=0;
                                    }           
                        }
                 ?>

// and using concantation i'm inserting button values seqhence into database // like user will click on first 5 button i will insert seq=1-2-3-4-5 which are html button values

// and then using php insert query i'm inserting the sequene in db // concantation code i'm not given here

$con="INSERT INTO `vector`.`signup` (`userid` ,`seq`)VALUES ('".$usr."', '".$seq."')";

     mysql_query($con) or die  ('Bad Input');
?>

see this databse picture

http://i53.tinypic.com/1zudjo.jpg

Now my prb is i want to store different values in database .. for each buton like btn1='1' has value 1 when user will click i want to store diffvalue like 'a1' . which should not available to user on client side .. i want to do with php ..

how can i change html button value with php code to store in databse...

i want btn1='1' to be btn1='a1' in database..

1
  • So you mean to store something that is not in the button itself? If yes, is 'a' in a1 always the same.. or will it change? Commented Feb 27, 2011 at 7:31

1 Answer 1

1
$databasevalue = 'a' . $_POST['btn1'];

Seems rather obvious... just prepend whatever you want to the value coming out of the form.

Sign up to request clarification or add additional context in comments.

2 Comments

bt this value will echo in HTML source ??
Then remove the value before building the form next time around? Or store the special value seperately from the form value. Sounds like you're making a mountain out of a mole hill. If this special value can't ever be seen by a user, then you should never mix it in with data that will be seen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.