By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,359 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

selected checkbox value stored in database

P: 10
hi ,

i am new to php.just i am writing checkbox coding. how to store the selected check box value in Mysql.
[php]
$sql=mysql_query("select * from $ttablename") or die(mysql_error());

while($row=mysql_fetch_row($sql))
{
echo"<tr>
<td><input type='checkbox' name='arr[]'></td>
<td >$row[0]</td>
<td>$row[1]</td>
<td>$row[2]</td>
</tr>";
}
[/php]
please reply me
Feb 15 '08 #1
Share this Question
Share on Google+
3 Replies


ronverdonk
Expert 2.5K+
P: 4,258
welcome to TSDN!

In order to help you, show all code you have developed so far. The code you showed does not include a <form> with a submit statement.

So let's see all of it and do not forget to include that code within the appropriate code tags!.. Please read the Posting Guidelines.

Ronald
Feb 15 '08 #2

P: 10
welcome to TSDN!

In order to help you, show all code you have developed so far. The code you showed does not include a <form> with a submit statement.

So let's see all of it and do not forget to include that code within the appropriate code tags!.. Please read the Posting Guidelines.

Ronald




<?php
include("conn.php");
$sel= mysql_select_db("sangoma");
//include("function.php");

?>
<div id="layout1">
<center>
<table border="0" cellpadding="1" cellspacing="1">
<form method='post' action='<?php $_SERVER[PHP_SELF] ?>' name='agentdisp'>
<tr>
<td align="right">Campaign Name:</td><td>
<?
$tab= $_GET['tab'];
$_SESSION['$t_tab']=$tab;
$r = mysql_query("show tables");
echo "<select name=tablename value=\'\' size=1 onchange=\"reload(this.form)\">";
echo "<option value=''>Table Name</option>";
while($res1 = mysql_fetch_row($r)) {
if($res1[0]==@$tab){
echo "<option selected value='$tab'>$tab</option>"."<BR>";
}else{
echo "<option value='$res1[0]'>$res1[0]</option>";}
}
echo "</select>";
?>
</td>
</tr>
<tr><td colspan="2" align="center"><input type="submit" name="submit" value="Submit" class="butt" /></td></tr>
</form>
</table>
</center>


<?
$submit=$_POST['submit'];
if($submit=='Submit')
{

//mysql_query("delete from sangomatemp.temp") or die(mysql_error());

$ttablename = $_POST{'tablename'};




/*echo"<table border=0 cellpading=0 cellspacing=0>";
echo"<td>phone</td>";
echo"<td></td>";
echo"<td></td>";
echo"<td></td>";
echo"<td></td>";
echo"<td></td>";
echo"<td></td>";
echo"<td></td>";
echo"<td></td>";
echo"<td>l</td></tr>";*/



echo "<table border=1 align=center id='thetable'>
<tr><td class='th'>Select</td><td class='th'>SKU #</td><td class='th'>Description</td><td class='th'>List Price with Customs</td></tr>";

//$q="select phone from newtest where phone<>''";
//$q1=mysql_query($q) or die("could not connect".mysql_error());


echo $ttablename;

$sql=mysql_query("select * from $ttablename") or die(mysql_error());

while($row=mysql_fetch_row($sql))
{

echo"<tr>
<td><input type='checkbox' name='arr[]'></td>
<td >$row[0]</td>
<td>$row[1]</td>
<td>$row[2]</td>


</tr>";
}


echo "</table>";

echo"<table border=0 cellspacing=0 cellspadding=0>";

echo"<input type='submit' name='submit' value='Submit' />";
//echo "<tr><td><a href='sub_drive.php' target='_blank'>Next</a></td></tr></table>";

}
?>

</div>
</DIV>
</DIV>

<script language="javascript">
function alternate(id){
if(document.getElementsByTagName){
var table = document.getElementById(id);
var rows = table.getElementsByTagName("tr");
for(i = 0; i < rows.length; i++){
//manipulate rows
if(i % 2 == 0){
rows[i].className = "even";
}else{
rows[i].className = "odd";
}
}
}
}
</script>
</body>
</html>
Feb 15 '08 #3

ronverdonk
Expert 2.5K+
P: 4,258
Your second submit - and I cannot give a line number because the code is not within code tags - is not attached to a form so it will not get submitted.

And for the second time: enclose any code within coding tags!. The way it looks does not invite many members to scan through it.

Ronald
Feb 15 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.