php - Query does not work when i fetch data and insert it into a table -
i trying insert table results of select statement table. select statement works insert statement not work. please me.
$query="select * subject sub_code = '$enrol' "; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $csubject=$row['sub_name']; $cday=$row['sub_day']; $ctime=$row['sub_time']; echo "<strong>". $csubject . "</strong>"; } $query = mysql_query("insert client (client_csub_code,client_csub_name,client_csub_day,client_csub_time) values ('$enrol','$csubject','$cday','$ctime')"); header("location:homeclient.php"); ?>
you asked how these 2 1 query.
this how:
$query = mysql_query("insert `client` ( `client_csub_code`, `client_csub_name`, `client_csub_day`, `client_csub_time` ) select `sub_code`, `sub_name`, `sub_day`, `sub_time` `subject` `code` = '$enrol'"); // add error checking if ( mysql_errno() ) echo mysql_error();
Comments
Post a Comment