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

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -