Darkmatter5 Posted November 14, 2008 Share Posted November 14, 2008 Here's my update code <?php if(isset($_POST['editjob'])) { include 'library/dbconfig.php'; include 'library/opendb.php'; //handling textboxes foreach (array('job_number','job_desc','job_loc','section','lot_blk','fb_pg','fnd_date','acerage','memo_info','vol_pg','estimate','amount','assign_date','completion_date') as $field1) { if ($_POST[$field1]) { $data[]=$field1. "=" ."'{$_POST[$field1]}'"; } } //handling dropdown lists foreach (array('client_id','county_id','survey_id_1','survey_id_2','survey_id_3','subdivision_id','type_id_1','type_id_2','type_id_3','employee_id') as $field2) { if ($_POST[$field2]!="---Select---") { $data[]=$field2. "=" ."'{$_POST[$field2]}'"; } } //insert data into table foreach ($data as $value) { $updatedata="UPDATE $dbname.jobs SET $value WHERE job_id='{$_POST['job_id']}'"; mysql_query($updatedata) or die(mysql_error() .": $updatedata"); } //echo "Job " .$_POST[job_number]. " UPDATED to jobs table..."; include 'library/closedb.php'; header("Refresh: url='{$_SERVER['PHP_SELF']}?job_id={$_POST['job_id']}'"); } ?> I've read up on the header function and it says in PHP 4.0 and up you can use Output Buffer to get past the restriction of using header after other data has been output to the page. How do I do this? How do I use header and output buffering to accomplish this? Link to comment https://forums.phpfreaks.com/topic/132741-how-to-reload-a-page-after-an-update-is-made-to-a-database/ Share on other sites More sharing options...
flyhoney Posted November 14, 2008 Share Posted November 14, 2008 Don't do it. If you need to do it then there is probably a better way to structure your code. But if you must... <?php // call this at the beginning ob_start(); // output anything you want here, it won't go to the browser... echo 'lolololz'; // grab the output at the end of the script $output = ob_get_flush(); // either echo the output or do a header redirect echo $output; ?> Link to comment https://forums.phpfreaks.com/topic/132741-how-to-reload-a-page-after-an-update-is-made-to-a-database/#findComment-690305 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.