|
Posted by strawberry on 07/25/06 15:34
Jerry Stuckle wrote:
> sachu wrote:
> > Hi , What i exactly needed is, I need user to build his own query [only
> > the SELECT statement] on the client side. Something like user selecting
> > column name from the listbox,etc and selecting the condition.
> > for example: condition like between two dates or something like based
> > on employee name, or product name.
> > what i mean to say is, it should work for all possible condition. and
> > retrieved data should be displayed in the table.
> >
> > Am using PHP 5.0, MySQL and IIS
> >
> > Can anyone provide mean the code snippets similar to the above idea. I
> > have very much shortage of time to really do my own.
> >
> > Please help....
> > Thanks in advance..
> >
>
> Impossible to do without knowing the structure of your tables, etc.
>
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================
If you haven't got a lot of time then you're in trouble but anyway,
here's a very basic (and abridged), single-page example to get you
started:
It uses a value passed to the end of the url to reorder the result list
-
but you can adapt this technique (usually with a 'submit' button
attached to a form) to suit your purposes...
<?
//Allow user to sort list by '$key'
$iskey = @$_GET['key'];
if (is_null($iskey)){
$key = 'f_name';}
else{$key = $iskey;}
$query = "SELECT * FROM table1 ORDER BY $key ASC;";
$result = mysql_query($query1) or die ("Could not execute query1.");
/* Display (abridged) results in a table */
echo "<table width='100%'>\n";
echo "<tr valign='top'>\n";
echo "<th><a href='$PHP_SELF?key=f_name'>First name</a></th>\n";
echo "<th><a href='$PHP_SELF?key=l_name'>Last name</a></th>\n";
echo "<th><a href='$PHP_SELF?key=company'>Company</a></th>\n";
echo "</tr>\n";
echo "</table>\n";
?>
So not exactly 'impossible' after all.
[Back to original message]
|