RESET issue

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
leoden
Forum Newbie
Posts: 21
Joined: Sat May 24, 2003 8:48 pm

RESET issue

Post by leoden »

Hi guys.

I have a web page that displays all the Items in a catalogue & images. I also have a search button so users can retrive a list of specific items.

the code is as follows

Code: Select all

<?php
echo "<form method=POST'' action=''> ";
echo "Enter Search word then click Search!: <input type='text' name='searchtext'> ";
echo "<input type='SUBMIT' value='Search'> ";
echo "</form> ";

// Connection Details

mysql_connect($host,$username,$password) or die("Cannot connect to the database.<br>" . mysql_error()); 
mysql_select_db($database) or die("Cannot select the database.<br>" . mysql_error()); 

if(!isset($page)) &#123; 
	$page = 0; 
&#125; 

$limit = 5; // Entries per page 

if ( $searchtext == "" )&#123;
	$sql = "SELECT SaleNumber,LotNo,Description,LowEst,HighEst,Image FROM $table ORDER BY LotNo LIMIT $page,$limit"; 
		&#125; else &#123;
	$sql = "SELECT SaleNumber,LotNo,Description,LowEst,HighEst,Image FROM $table WHERE Description LIKE '%$searchtext%' ORDER BY LotNo LIMIT $page,$limit"; 
&#125;

$query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error()); 

// Retrieve Data and output to table etc etc

// Next/Previous page Code

?>
My question is that i need a reset button to effectively get out of the refresh the page as if no search text had been entered i.e. the page loads up showing the first 1 to 5 sale items again.

Any ideas

Cheers
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Simply put:

Code: Select all

<?php
echo "<a href="$PHP_SELF">Refresh page</a>\n";
?>
Hopefully that's what you mean.
Image Image
leoden
Forum Newbie
Posts: 21
Joined: Sat May 24, 2003 8:48 pm

Post by leoden »

Cheers Mate spot on, can you link that to a button?
Gleeb
Forum Commoner
Posts: 87
Joined: Tue May 13, 2003 7:01 am
Location: UK
Contact:

Post by Gleeb »

Code: Select all

<?php
echo '<form action="'.$_SERVER['PHP_SELF'].'"><input type="submit" text="Refresh Page" method="POST"></form>'; // POST, so it has a pretty URL
?>
That works, but don't do it like that, there but be FAR better ways.
Post Reply