Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a link 2

Status
Not open for further replies.
Jun 9, 2004
188
US
Hello everyone. Just a quick question. I have an index page (index.php) that shows 15 recent enteries using a query like this:

$query="SELECT id, title, DATE_FORMAT(date,'%M %D, %Y') AS date FROM article ORDER BY ID DESC LIMIT 15";

I would also like to have a link "View All" that would contain the query:

$query="SELECT * FROM article ORDER BY ID DESC";

I am not really sure on how to incorporate this link without creating a new page like viewall.php.

Thanks for any help.
 
In the page create an element (checkbox, button, link, something), name it something like "showall" for example and check for if that element was activated in your php app:

Code:
$query = "the select for all";
if ( ! isSet( $_REQUEST[ 'showall' ] ) ) {
   $query = $query . " LIMIT 15";
}
 
Not really sure I understand. What should my link look like:

Code:
<a href="index.php?=showall">View All</a>

$query = "SELECT * FROM article ORDER BY ID DESC";
if ( ! isSet( $_REQUEST[ 'showall' ] ) ) {
   $query = $query . " LIMIT 15";

So if it is not showall it will default to limit 15?

Sorry to be a pain but I would like to try and understand it rather then just copying.
 
To illustrate ericbrunson's post:
Link example:
Code:
<a href="view.php?showall=true">View all</a>

In a form:
Code:
<form action="view.php" method="post">
<input type="checkbox" name="showall" value="true"><label for="showall">View all</label>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top