Registration
<?php
session_start();
$connection=Mysql_connect('localhost','admin','123');
Mysql_select_db('db',$connection);
if(array_key_exists('insert',$_POST))
{
$query="select * from pharmacy";
$result=mysql_query($query);
if (!$result)
{
print(mysql_errno() .":". mysql_error());
}
$num=Mysql_num_rows($result);
$num1=Mysql_num_fields($result);
if($num>0)
{
echo "<table border=2>";
for($i=0;$i<$num;$i++)
{
$row=mysql_fetch_row($result);
echo "<tr>";
echo"<td><input type='Checkbox' name='p[$i]' value='on' unchecked /></td>";
echo"<td>$row[0]</td>";
echo"<td><input type='txt' name='q[$i]' /></td>";
$r[$i]=$row[0];
if(isset($_POST['q']))
$q[$i]=$_POST['q'];
echo"</tr>";
}//for
echo"</table>";
}
if(isset($_POST['p']))
foreach($_POST['p'] as $key=>$value)
{
if($value=="on")
{
$u=$_SESSION['t'];
$query8="insert into $u(name,qun)values('$r[$key]',$q[$key])";
echo $query8;
$result8 = mysql_query($query8);
//header("Location: show.php?");
}
echo $q[0];
}//for
}
?>
<input type="submit" name='insert' value="insert Drugs"/>
</form>
</body>
i have a table that has rows i insert the chosen ones in another table in mysql but when i want to insert the content of texts i have problem my problem is here:if(isset($_POST['q'])) $q[$i]=$_POST['q']; it can't be set how can i correct it?