Code Comments
Programming Forum and web based access to our favorite programming groups.Wondering if anyone is aware of php source out there that takes an SQL Query, displays the results in tabular fashion (i.e. there is likely more than one record returned by the query) allowing the user to then pick which row from that he wants by simply clicking upon it (i.e. it can return the key value for a given row). Anyone aware of anything like this? THanks, Ike
Post Follow-up to this messageIke wrote: > Wondering if anyone is aware of php source out there that takes an SQL > Query, displays the results in tabular fashion (i.e. there is likely more > than one record returned by the query) allowing the user to then pick > which row from that he wants by simply clicking upon it (i.e. it can > return the key value for a given row). > > Anyone aware of anything like this? THanks, Ike phplens seems to be waht you're looking for - note that it's commercial software. There's also an editable table at phpclasses (can't remember the name of the project). Or there's a table class at http://exorsus.net/software/ but last time I looked the developer was looking for payment before publishing any docs. HTH C.
Post Follow-up to this messageIke wrote:
> Wondering if anyone is aware of php source out there that takes an SQL
> Query, displays the results in tabular fashion (i.e. there is likely more
> than one record returned by the query) allowing the user to then pick whic
h
> row from that he wants by simply clicking upon it (i.e. it can return the
> key value for a given row).
>
> Anyone aware of anything like this? THanks, Ike
>
>
I may have misunderstood (in which case, apologies!), but can't you do
the query, iterate thru' all the rows to create a table and include a
link which displays just that row's information?
An example using an imaginary users table in a MySQL database (the
theory's sound for all dbms's - I can just remember the syntax for MySQL
more easily :-) :
---------start of php-----------------
<?php
//Query the db for info (in this case username and id - could be more
complex)
$sql = "SELECT userid, username FROM users;";
$result = mysql_query($sql) or die(mysql_error());
//Create the start of the table
?>
<table>
<tr>
<td>User ID</td>
<td>Username</td>
<td>Options</td>
</tr>
<?php
//Iterate thru the rows returned from the db
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>$row['userid']</td>"; //The user id
echo "<td>$row['username']</td>"; //the username
echo "<td>";
echo "<a href="".$_SERVER['PHP_SELF']."?showuserid=$row['userd']\">Show
this row</a>"; // This line would create a link for the appropriate
userid. echo "</td>";
echo "</tr>\n";
}
//Finish the table
echo "</table>\n";
?>
---------End of PHP----------------
Does that make any sense? The link will include the id for the
appropriate row (in this case, the userid) - you could use the variable
(in this case $_GET['showuserid'] or $showuserid if you've got
register_globals turned on) to query the db for more information about
that row/record.
Ed
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.