If I understand you correctly, then you could try something like this:

=======Page 1:
Select info to view...
<input type="checkbox" name="columns[]" value="Name"> Name<br>
<input type="checkbox" name="columns[]" value="Email"> Email<br>
<input type="checkbox" name="columns[]" value="City"> City

=======Page 2:
$query  = 'SELECT ';
$first = true;
foreach ($columns AS $value) {
   if (!$first) {
     $query .= ', ';
   }
   else {
     $first = false;
   }
   $query .= $value;
}
$query .= 'FROM MyTable ';
$query .= 'ORDER BY Name';
$result = mysql_query($query);
echo '<table>';
while ($row = mysql_fetch_row($result)) {
   echo '<tr>';
   foreach ($row AS $value) {
     echo "<td>$value</td>";
   }
   echo '</tr>';
}
echo '</table>';

Obviously this is a pretty rough outline, but it gives you a basic idea of 
the way you could do this.  You can add bells & whistles and make it look 
nicer, add error checking, stuff like that.

-Mike

At 09:41 AM 4/11/2002 -0500, R.S. Herhuth wrote:

>I'm new to php and I'm trying hard to get a grasp on pulling data from
>SQL Server.
>
>I'm looking for an efficient method for making dynamic queries to SQL server.
>
>
>
>Basically what I have created so far is a page that dynamically builds
>all of the column names of a database.  I have assigned each a unique
>variable name.  When the user selects the check box next to the name and
>submits the form, I am using the HTTP_POST_VARS() to explode out the
>variables on the following page.  What I need to do though is create a
>way to dynamically query the DB only returning the selected columns.
>What is an efficient way of doing this?
>
>Does anyone know of any tutorials or examples that can get me close?
>
>Ron
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php


Mike Flynn - Burlington, VT
http://www.mikeflynn.net/ - [EMAIL PROTECTED]
home=>work=>home=>store=>home [repeat daily]


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

Reply via email to