Hi everyone...
After get fiddling for couple and hours it seems I'm still can't find the solution for my problem maybe a simple problem for most of you here...
Okay let me get thing straight...what I want try to do is refresh the page itself after success adding the new record...previously..the paginating part works okay but now it's seem turn weird..and one more things the records will keep add new record eventhough I'm not adding new record...here's the screen shot for what I'm try to do..
http://fifin04.propertyaccess.com.my/teststuff/form.JPG
and here's are the code I'm using currently..
$news_tittle = mysql_escape_string($_POST['news_tittle']);
$news_txt = mysql_escape_string($_POST['news_text']);
$dbhostname = "localhost";
$dbusername = "root";
$dbpassword = "";
$dbname = "markedmedia";
$db = mysql_connect($dbhostname, $dbusername, $dbpassword);
mysql_select_db($dbname, $db) or die("ERROR: Cannot connect to the database");
///////SAVING NEW RECORD///////////////////
$query = "INSERT INTO news SET
headertxt='$news_tittle',newstxt='$news_txt',
timedate_news = NOW()
";
$proceedSQL = mysql_query($query) or die(mysql_error());
//////FORMATTING RECORDSET///////////////
$rowsPerPage = 3;
$pageNum = 1;
if(isset($_GET['page'])){
$pageNum = $_GET['page'];
}//end if
$offset = ($pageNum - 1) * $rowsPerPage;
$query = "SELECT * FROM news ";
$pagingQuery = "LIMIT $offset, $rowsPerPage";
$result = mysql_query($query . $pagingQuery) or die('Error, query failed');
////////////////////////////////////////////////////////////////////////////
$result = mysql_query($query) or die('Error, query failed');
$numrows = mysql_num_rows($result);
$maxPage = ceil($numrows/$rowsPerPage);
$self = $_SERVER['PHP_SELF'];
if ($pageNum < $maxPage){
$page = $pageNum + 1;
echo "<a href=\"$self?page=$page\">Next</a>\n";
}
echo "$pageNum of $maxPage";
if ($pageNum > 1 && ($pageNum <= $maxPage)){
$page = $pageNum - 1;
echo "<a href=\"$self?page=$page\">Previous</a>\n";
}
If you guys wants the sample page can download here...
http://fifin04.propertyaccess.com.my/teststuff/addnew3.zip
Hope someone can tell me where is my wrong...at least some shed on light will be great
Thanks