Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Insert data in to the textbox in PHP Reply To: Insert data in to the textbox in PHP

#169597
dnyanesh
Participant

i want to update selected rows when i will click on submit button . here check box is not getting value . kindly help me out

<!DOCTYPE html>
<html>
<head>
<title>Dhanaji Nana Mahavidyalaya</title>
<link rel=”stylesheet” type=”text/css” href=”style.css”>
</head>

<body class=”body”>

<?php
session_start();
?>
<form action=”” method=”post”>

<h2><br>
Welcome <?php echo $_SESSION[“username”]; ?></h2>

<h3 align=”center” style=”color:#F00″>Login Here</h3>
<h6>Student Login » Parents Login » Admin Login </h6>

<?php include(‘includes/nav.php’); ?>

<legend>Student Information</legend>

<table style=”border-collapse:collapse; “width=”589″ border=”1”>
<tr>
<td>Select</td>
<td>Name</td>
<td>Degree</td>
<td>Birthdate</td>
<td>Family Income</td>
<td>Father Name</td>
<td>Roll No</td>
<td>Update</td>
<td>Delete</td>
<?php // <td>Dept Name</td>?>
</tr>
<?php$con = mysqli_connect(“localhost”,”root”,””,”collage”);
mysqli_select_db($con , “collage”);

//$sql =”select * from stud_info”;
$sql = mysqli_query($con , “SELECT * FROM stud_info”);
//$result = mysql_query($sql);

$count = mysqli_num_rows($sql);

while($rows = mysqli_fetch_array($sql, MYSQLI_ASSOC ))
{
?>

<tr>
<td ><input type=”hidden” name=”checkboxid[]” value=”<? echo $rows[‘stud_id’]; ?>” /><? echo $rows[‘stud_id’]; ?></td>

<td><input type=”checkbox” name=”onoffcheckbox[]” id=”onoff” value=”<?php echo $rows[‘stud_id’]; ?>”/></td>

<td><input type=”text” name=”name<?php $rows[‘stud_id’]; ?>” id=”name” value=”<?php echo $rows[‘name’]; ?>” /></td>
<td><input type=”text” name=”Degree<?php $rows[‘stud_id’]; ?>” id=”Degree” value=”<?php echo $rows[‘Degree’]; ?>” /></td>
<td><input type=”text” name=”birthdate<?php $rows[‘stud_id’]; ?>” id=”birthdate” value=”<?php echo $rows[‘birthdate’]; ?>” /></td>
<td><input type=”text” name=”income<?php $rows[‘stud_id’]; ?>” id=”income” value=”<?php echo $rows[‘income’]; ?>” /></td>
<td><input type=”text” name=”fathername<?php $rows[‘stud_id’]; ?>” id=”fathername” value=”<?php echo $rows[‘fathername’]; ?>” /></td>
<td><input type=”text” name=”roll_no<?php $rows[‘stud_id’]; ?>” id=”roll_no” value=”<?php echo $rows[‘roll_no’]; ?>” /></td>

<td>“> Edit </td>
<td>“>Delete</td>
</tr>
<?php } ?>

<tr>
<td colspan=”9″><input type=”button” value=”Add Student information” /></td></tr>

<tr>

<td colspan=”9″>” ><input type=”button” value=”Add”/> <input type=”submit” value=”Update”/><input type=”submit” value=”Delete”/></td>
</tr>
</table>
<?php
if($_POST)
{
echo ”

";
          print_r($_POST);
          die('svsdfsf');

foreach($_POST[‘stud_id’] as $id )
{
$sql1=”UPDATE “.$stud_info.” SET onoff='”.$_POST[“onoff”.$id].”‘, name='”.$_POST[“name”.$id].”‘, Degree='”.$_POST[“Degree”.$id].”‘, birthdate='”.$_POST[“birthdate”.$id].”‘,income='”.$_POST[“income”.$id].”‘,fathername='”.$_POST[“fathername”.$id].”‘,roll_no='”.$_POST[“roll_no”.$id].”‘ WHERE stud_id='”.$id.”‘”;
$result1 = mysql_query($sql1);
}
}
if($result1)
header(“location:stud_info.php”);

?>

</fieldset>

</form>
</body>
</html>