473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

selected checkbox value stored in database

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
3 2512
ronverdonk
4,258 Expert 4TB
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
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
4,258 Expert 4TB
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

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

Similar topics

3
by: Sarah West | last post by:
Hi, I have the following problem; This is my form, i would like to default the select box to USA, and default the text field to a name such as 'Sarah' and the hidden field to another number...
4
by: Jack | last post by:
Hi, I have a checkbox the value which goes to a database via a asp page that builds the sql string. In the front end asp page, the checkbox code is written as follows: <i><input...
3
by: Jack | last post by:
<i><input type="checkbox" name="chk_Complete" value="TRUE" <%Response.Write l_IsChecked%>"<%if cbool(l_IsChecked) then Response.Write " checked" Else Response.Write " unchecked"%>> The above...
0
by: Kumar | last post by:
Hi , I am using the article code shown in below url: http://www.codeproject.com/aspnet/xmlxsltransformer.asp?df=100&forumid=118504&select=1170328 This article is very cool feature. I...
4
by: M | last post by:
Hello, I would like to get a value for a non selected checkbox in a form. Imagine my form contains : <input type='checkbox' name='t' value='1'> <input type='checkbox' name='t' value='1'> ...
1
by: snsit1 | last post by:
Hello - i am wondering if anyone can help, I am fairly new to javascript / html and am having difficulty getting selected options ticked using check boxes out to a .txt file and have another script...
10
by: aniltc | last post by:
I have a list of users(signed for a newsletter).I'm retrieving the list from a database when the admin clicks on a button. There are maximum 10 users diplayed per page.For example,if I had 30 users...
37
by: viki1967 | last post by:
Hi all. I have this simple form. I need if checkbox C_1 is selected: 1) field name="n_1" is required and accept only numbers; 2) field name="n_2" is required and accept only numbers; I...
9
by: raamay | last post by:
I have six checkboxes as shown below: <table> <tr> <td><input name="spec1" type="checkbox" value="0" tabindex="11" /><label id="label">Bridge Construction</label></td> </tr> <tr> <td><input...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.