Page 1 of 1

RESET issue

Posted: Thu May 29, 2003 2:17 pm
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

Posted: Thu May 29, 2003 6:15 pm
by phice
Simply put:

Code: Select all

<?php
echo "<a href="$PHP_SELF">Refresh page</a>\n";
?>
Hopefully that's what you mean.

Posted: Thu May 29, 2003 7:19 pm
by leoden
Cheers Mate spot on, can you link that to a button?

Posted: Fri May 30, 2003 3:47 am
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.