[英]Replace html button value with php and store it in database?
//Following code to generate 25 Button with unique name for each button //以下代码生成25个按钮,每个按钮具有唯一的名称
// 25 buttons contains value from 1 to 25 // 25个按钮的值从1到25
// like btn1='1',btn2='2' ... btn25='25' //像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 //并且使用conantation,我将按钮值seqhence插入数据库// //就像用户将单击前5个按钮一样,我将插入seq = 1-2-3-4-5,它们是html按钮值
// and then using php insert query i'm inserting the sequene in db // concantation code i'm not given here //然后使用php insert查询,我将sequene插入db中//确认代码,在此未给出
$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 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' . 现在我的prb是我想在数据库中存储不同的值..对于每个btn,像btn1 ='1'的值是1,当用户单击时我想存储diffvalue像'a1'。 which should not available to user on client side .. i want to do with php .. 客户端上用户不应该使用的..我想用php ..
how can i change html button value with php code to store in databse... 我如何更改带有PHP代码的html按钮值以存储在数据库中...
i want btn1='1' to be btn1='a1' in database.. 我希望btn1 ='1'在数据库中是btn1 ='a1'。
$databasevalue = 'a' . $_POST['btn1'];
似乎很明显……只要在表单中附加任何您想要的值即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.