[ask]Auto Refresh

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nitediver
Forum Contributor
Posts: 109
Joined: Tue Feb 24, 2009 9:05 am

[ask]Auto Refresh

Post 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>
 
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: [ask]Auto Refresh

Post by pickle »

Do your record deletion & message display before you query for the list of all records.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
nitediver
Forum Contributor
Posts: 109
Joined: Tue Feb 24, 2009 9:05 am

Re: [ask]Auto Refresh

Post by nitediver »

no, its after,

here...

Code: Select all

 
if ($qwerydel)
     {
     print "Record Deleted<br>";
     }
 }
 
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: [ask]Auto Refresh

Post by pickle »

That wasn't a question (no question mark). That was a statement.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
nitediver
Forum Contributor
Posts: 109
Joined: Tue Feb 24, 2009 9:05 am

Re: [ask]Auto Refresh

Post 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..
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: [ask]Auto Refresh

Post by pickle »

If you've got another question, create another thread so you have a better chance of getting help.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply