How do I send one table values to another table with new fields?
---------------i want store this data's to following table--
Code:
<?php
include("menu.php");
include("db.php");
//$id=$_REQUEST['id'];
$min=$_REQUEST['min'];
$exam=$_REQUEST['exam'];
$class=$_REQUEST['class'];
?>
</head>
<body>
<table>
<tr>
<td>
<?php
//echo $id=$_POST['id']; echo "<br>";
$min=$_POST['min']; echo "<br>";
$mentry=$_POST['mentry']; echo "<br>";
if ($mentry=="Batch")
{
if(mysqli_connect_errno())
{
echo "Failed to connect to MYSQL: " .mysqli_connect_error();
}
//$sql="select id,name,regno,class,batch,institute from student where class = '$class'";
$sql="SELECT * FROM student WHERE batch ='$min' and class='$class'";
$resource=mysql_query($sql,$conn); ?>
Selected students from:<?php echo $_REQUEST['class']?> Std and<?php echo $_REQUEST['min']?> Batch.
<?php echo "<table align=\"center\" border=\"1\" width=\"100%\">
<tr>
<td><b>Id</b></td>
<td><b>Name</b></td>
<td><b>Register number</b></td>
<td><b>Class</b></td>
<td><b>Batch</b></td>
<td><b>Exam</b></td>
<td><b>Institute</b></td>
<td><b>Student mark</b></td>
<td><b>Add mark</b></td>
</tr> ";
while($row=mysql_fetch_array($resource))
{
echo "<tr>
<td>".$row['id']."</td>
<td>".$row['name']."</td>
<td>".$row['regno']."</td>
<td>".$row['class']."</td>
<td>".$row['batch']."</td>
<td>".$_REQUEST['exam']."</td>
<td>".$row['institute']."</td>
<form name=\"addmarks\" method=\"post\" action=\"storemark.php\">
<td>"."<input type=\"text\" name=\"stumark\">"."</td>/*this is my new field as student mark but it cant be send next page i give this name to belowed <a href link> it give undeifinded index stumark so pls help me how to store this details */
</form>
<td><a href=\"storemark.php?id= ".$row['id']."&exam= ".$_REQUEST['exam']."&regno= ".$row['regno']."
&name= ".$row['name']."&class= ".$row['class']."&batch= ".$row['batch']."
&institute= ".$row['institute']."&fname= ".$row['fname']."&mname= ".$row['mname']."&mobile= ".$row['mobile']."
&email= ".$row['email']."\"><input type='submit' name='addmark' value='Add mark'>
<img width='100px' height='20px'src=\"send.png\"/></a>
</td>
</tr>";
}
echo "</table>";
} ?>
Code:
<?php
include("menu.php");
include('db.php');
$id=$_REQUEST['id'];
$exam=$_REQUEST['exam'];
$regno=$_REQUEST['regno'];
$name=$_REQUEST['name'];
$class=$_REQUEST['class'];
$batch=$_REQUEST['batch'];
$institute=$_REQUEST['institute'];
$fname=$_REQUEST['fname'];
$mname=$_REQUEST['mname'];
$mobile=$_REQUEST['mobile'];
$email=$_REQUEST['email'];
$stumark=$_REQUEST['stumark'];
echo "<pre>", print_r($_REQUEST, true), "</pre>";
if(mysqli_connect_errno())
{
echo "Failed to connect to MYSQL: " .mysqli_connect_error();
}
echo $sql=("insert into ".$exam." (id,exam,regno,name,class,batch,institute,fname,mname,mobile,email,stumark) values ('','$exam','$regno','$name','$class','$batch','$institute','$fname','$mname','$mobile','$email','$_POST[stumark]')");
if(!mysql_query($sql,$conn))
{
die ("An unexpected error occured while saving the record, Please try again!");
}
else
{
echo "marks added successfully!";
mysql_close($conn);
}
//header("Location:examentry.php");
?>
Comment