Forum Moderators: coopster

Message Too Old, No Replies

reg retrieving data from table

         

stranger2all

3:18 pm on Jan 13, 2012 (gmt 0)

10+ Year Member



Hello,
i need to show a few columns from the table with a hot link to the key column. once the customer clicks the key column it should display all the other fields from the table relevant to that key. I appreciate if you can share me the logic... as of now, i have just been able to display the data from the tables.

rocknbil

5:07 pm on Jan 13, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard stranger2all, more info will be needed but basically you'll need to build your query based on input (and, this post does not cover the critical step of cleansing and verifying input.)

Let's say your output looks something like this

id user name address blah
1 rocknbil nowhere some value

Your link could look like

<a href="script.php?id=1">rocknbil</a>

So you build your query like

$where = null;

if (isset($_GET['id']) and is_numeric($_GET['id']) and ($_GET['id'] > 0)) {
$where .= " id=".$_GET['id'];
}

$select = "select * from table";
if ($where) { $select .= " where $where"; }

As said that's probably not what you're asking, more info needed, but shows a dynamic build of the select statement based on input.