Forum Moderators: coopster

Message Too Old, No Replies

best PHP command for returning specific values from MySQL table?

         

bessington

7:28 pm on May 16, 2005 (gmt 0)

10+ Year Member



I'm looking to write a PHP script that will function like vlookup in excel.. but using a MySQL table.

here's an example of how vlookup works:

[techonthenet.com...]

I basically want to be able to 'lookup' a row based on two different fields. For example, I want to query the Product field in a table to see it contains the value of 'dictionary', if so I want to query another field in the row for Language 'french'. If both are true I want to print out that whole row - and I want it to print out all rows that have these two fields set to those particular values. Make sense? Is this possible?

Thank you!

Thanks!

supermanjnk

8:54 pm on May 16, 2005 (gmt 0)

10+ Year Member



this should do what you want.

<?
$query = mysql_query ( "SELECT * FROM items WHERE product='dictionary' AND language='french' " );

echo "<table border=\"1\">";
while ($get_query = mysql_fetch_row($query)){
echo "<tr>";
foreach ($get_query as $rows){
echo "<td>$rows</td>";
}
echo "</tr>";
}
echo "</table>";
?>

bessington

9:45 pm on May 16, 2005 (gmt 0)

10+ Year Member



I will try this.. thanks so much!