Re: Filtering Data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You could yuse it only when you have a value


$sql_where = '';

$get_data_query = "select a, b, c from table ";

$sql_orderby = "order by $sort_field $sort_order";


if (isset($_REQUEST['state']))
{
 $sql_where = " where state = '" . $_REQUEST['state'] . "' ";
}

$sql = $get_data_query . $sql_where . $sql_orderby;

$result = mysql_query($sql);



hth

bastien

From: kc68@xxxxxxxxxxx
To: php-db@xxxxxxxxxxxxx
Subject: Re:  Filtering Data
Date: Thu, 30 Jun 2005 08:42:21 -0400

That sounds like it, but help me a step further as I work from a template and haven't fully absorbed the syntax. My basic query is:

$get_data_query = "select a, b, c from table order by $sort_field $sort_order";

Where do I put the syntax you suggest? Where do the words go on which to click to execute? Also, I forgot that I'm using is zip codes to define states, so I'm doing, for example, 39999 > z > 29999 Thanks


**********
On Thu, 30 Jun 2005 08:17:17 -0400, Ross Honniball <ross@xxxxxxxxxxxxxxxxxxx> wrote:

Sounds like you just want some pretty basic variable substitution? As in the page is submitted with, say, state=T and you need to code your select statement like eg:

$query = "SELECT * FROM tbl WHERE state = '".$_REQUEST['state']."'";

then execute this query in your DB call.

Does that help?

kc68@xxxxxxxxxxx wrote:

How do I write a link which results in a page with part of the data in the mysql table and do that multiple times on a single php script page? That is, I want to be able to click on state names on a single page and bring up a page with only that state's data. I understand use of the "where" limitation, but I don't see how to code a line which will override the base "select" statement for the script. Thanks.

Ken



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux