简体   繁体   中英

process php whithout refreshing page

I have a problem with process to insert database, I have 3 tables and I want to proccess 3 tables alternately. example : I want to process insert into table A , from data table A continue to table B, and from data table B continue to table C whithout refreshing page, I want use Ajax , is there any script to used? my script this :

<?php 
break;
    case submit :
@mysql_query("INSERT INTO table_A(id,field1,field2,field3,date) VALUES ('','$field1','$field2','$field3','$datenow')");
echo "<meta http-equiv='refresh' content='0;URL=index.php?mod=process&act=step1'>";
break;
    case step1 :
@mysql_query("INSERT INTO table_B (id,field1,field2,field3,date) VALUES ('','$field1','$field2','$field3','$datenow')");
echo "<meta http-equiv='refresh' content='0;URL=index.php?mod=process&act=step2'>";
break;
    case step2 :
case step1 :
@mysql_query("INSERT INTO table_C (id,field1,field2,field3,date) VALUES ('','$field1','$field2','$field3','$datenow')");
echo "<meta http-equiv='refresh' content='0;URL=index.php?mod=process&act=OK'>";
?>

I think you need to go through some documentations and try to do something.

Learn what is ajax and use javascript here: http://www.w3schools.com/js/js_ajax_intro.asp

Use jquery for ajax here: http://www.w3schools.com/jquery/jquery_ref_ajax.asp

Finally switch statement syntax: http://www.w3schools.com/php/php_switch.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM