RE: Looking for pointers to mysql functions

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

 




> -----Original Message-----
> From: Stuart Felenstein [mailto:stuart4m@xxxxxxxxx]
> Sent: 11 November 2004 11:32
> To: php-general@xxxxxxxxxxxxx
> Subject:  Looking for pointers to mysql functions
> 
> 
> I'm building a search function and I think most of the
> search part is solid. 
> 
> Now I'm trying to figure out the results part.
> Since my results would return about 7 fields per
> record, I'm thinking mysql_fetch_row over mysql
> results works better ?
> But I don't want every field from the row returned,
> only specific ones.
> Also, I want to allow for all records that meet
> criteria to be returned, and will set up a user
> variable, so they can choose how many records per page
> come back.
> 
> Can anyone share some ideas or pointers to
> documentation that will allow me to set this up ?
> 
> Very much appreciated!
> Stuart
> 

Is this something like what you are after:

<?php
$sql = "SELECT col1, col2, col3, col4 as colx, col5
        FROM my_table
        WHERE col2 LIKE '%$search%'
        ORDER BY col3
	  LIMIT $from, $max_results";

$result = mysql_query($sql) or die ("Query failed: " . mysql_error());
while($row = mysql_fetch_assoc($result))
{
?>
    <tr>
      <td><?php echo $row['col2'] ?></td>
      <td><?php echo $row['colx'] ?></td>
    </tr>
<?php
}
?>

For details on how to do the x rows per page with previous and next see

http://www.phpfreaks.com/tutorials/43/0.php
or
http://www.phpfreaks.com/tutorials/73/0.php

HTH
Graham

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux