Web Hosting Talk







View Full Version : [PHP] Selecting a Row with a specific column


VH-Robert
07-08-2003, 11:01 PM
Ok.. I'm new to Php and am learning everything.

My question is this:

I have a table setup with the following:

column|Question|Answer|Category|
row|Question1|Answer1|general
row|Question2|Answer2|dns

How can I make to dispaly ONLY rows that contain the word "general" in their Category Column?

Right now i'm using the following to display ALL questions with answers

<?php

//
$result = @mysql_query('SELECT Question, Answer, Category FROM Faq');
if (!$result) {
die('<p>Error performing query: ' . mysql_error() . '</p>');
}

//
while ( $row = mysql_fetch_array($result) ) {
echo('<p><b>' . $row['Question'] .
'<p></b>' . $row['Answer'] .
'<br><i>' . $row['Category'] . '</i><p>');

}

?>


Any/ALL Help is appreciated!

null
07-08-2003, 11:08 PM
Hi,

Use this mySQL query

SELECT * FROM Faq WHERE Category = 'general'