Page 1 of 1

[ask]Auto Refresh

Posted: Tue Feb 02, 2010 8:28 am
by nitediver
This is the my table...
Image

My question is...
1.After i click the delete button how to auto refresh the page, ive put the refresh tag right after the "if" condition, but nothing happened...

2.If i scroll down & checked one of the record, the page then automatically scroll up, its become problem when i need to check more than one record, so i have to scroll up everytime i checking a name...

3.How to make this "Record Deleted", display on top/above the table, but i can only put that under the if condition?

This is my code, still messy...

Code: Select all

 
<?
require("conn.php");
$do = "select * from invoice order by date DESC";
$qwery = mysql_query($do);
?>
<html><body>
<div id="hdr">
<h1>
Confirmed Order</h1></div>
 
<form action="" method="POST">
<table width="100%" id="top"><tr><td>
<center>
<input type="submit" name="delete" value="Delete" id="delete">
<input type="submit" name="refresh" value="Refresh" id="refresh">
</center>
</td></tr></table>
<?php
print ("
<table width=\"100%\" id=\"head\">
  <tr>
    <td width=\"\"><input type=checkbox name=del[] id=del value=$result[id]></td>
    <td width=\"30%\"><b>Name</b></td>
    <td width=\"30%\"><b>Number</b></td>
    <td width=\"40%\"><b>Date</b></td>
  </tr>
</table>
");
while ($result = mysql_fetch_array($qwery))
{
print ("
<a href=\"#\" class=\"des\">
<table width=\"100%\" id=\"list\">
  <tr id=\"field\">
    <td width=\"\"><input type=checkbox name=del[] id=del value=$result[id]></td>
    <td width=\"30%\">$result[name]</td>
    <td width=\"30%\">$result[number]</td>
    <td width=\"40%\">$result[date]</td>
  </tr>
</table>
</a>
");
}
?>
<table width="100%" id="list"><tr><td>
<center>
<input type="submit" name="delete" value="Delete" id="delete">
<input type="submit" name="refresh" value="Refresh" id="refresh">
</center>
</td></tr></table>
<?
$refresh = refresh;
if ($refresh)
{
print "<meta http-equiv=\"refresh\">";
}
?>
<?php
$id = $_POST[del];
$multi = count($id);
 
if($_POST['delete'])
    {
    for ($i=0; $i<$multi; $i++)
    {
 
$dodel = "delete from invoice where id=$id[$i]";
$qwerydel = mysql_query($dodel);
print "<meta http-equiv=\"refresh\">";
}
 
if ($qwerydel)
    {
    print "Record Deleted<br>";
    }
}
?>
</form>
</body></html>
 

Re: [ask]Auto Refresh

Posted: Tue Feb 02, 2010 9:57 am
by pickle
Do your record deletion & message display before you query for the list of all records.

Re: [ask]Auto Refresh

Posted: Tue Feb 02, 2010 10:15 am
by nitediver
no, its after,

here...

Code: Select all

 
if ($qwerydel)
     {
     print "Record Deleted<br>";
     }
 }
 

Re: [ask]Auto Refresh

Posted: Wed Feb 03, 2010 10:14 am
by pickle
That wasn't a question (no question mark). That was a statement.

Re: [ask]Auto Refresh

Posted: Thu Feb 04, 2010 2:45 am
by nitediver
thanks but, never mind bout that,

I got new problem here...

after the record deleted, then display "Record Deleted", but the deleted record still display on the table until i refresh the page,

Code: Select all

 
<?php
$id = $_POST[del];
$multi = count($id);
 
if($_POST['delete'])
    {
    for ($i=0; $i<$multi; $i++)
    {
 
$dodel = "delete from invoice where id=$id[$i]";
$qwerydel = mysql_query($dodel);
}
 
if ($qwerydel)
    {
    print "<meta http-equiv=\"refresh\" content=\"1\">";
    print "Record Deleted<br>";
    }
}
?>
 
so, i put; line 17 code above,

Code: Select all

print "<meta http-equiv=\"refresh\" content=\"1\">";
right before,

Code: Select all

print "Record Deleted<br>";
But i got another problem...

the result is:
After record deleted > print "Record Deleted" > Refreshing page

but,

what i wanna do is:
After record deleted > Refreshing page > print "Record Deleted"

i hope anyone here can give me advice,
thanks..

Re: [ask]Auto Refresh

Posted: Fri Feb 05, 2010 1:37 pm
by pickle
If you've got another question, create another thread so you have a better chance of getting help.