This topic is locked

Calling SQL from table

12/7/2008 10:22:50 PM
PHPRunner General questions
W
webrider author

Apriciate any help I can get
I hope this is simple; I did not get any change to get it to work
I have a report to count the number of computer is I use this query it work fine
$link = mysql_connect("localhost", "f__froot55", "z23r9y9d9aeEEAaA");

mysql_select_db("amtr", $link);

$sql = "SELECT COUNT(N) FROM Report_b WHERE `b`.`CPU` >= 20 AND `b`.`PCTYPE` <= 5 ";

$result = mysql_query($sql);

if ($result !== false) {

$row = mysql_result($result, 0);

echo $row;

} else {

//sql error

}
What I'm looking for is:

Call the query from a table called Report_b

The table has 3 fields:

ID

Name:

SQL: where the SQL Query is saved "SELECT COUNT(N) FROM Report b WHERE `b`.`CPU` >= 20 AND `b`.`PCTYPE` <= 5"
$link = mysql_connect("localhost", "f__froot55", "z23r9y9d9aeEEAaA");

mysql_select_db("amtr", $link);

$sql = "what should I put in here to get the sql query from the table where ID = 1 or 2 or ...."; <<<<<<

$result = mysql_query($sql);

if ($result !== false) {

$row = mysql_result($result, 0);

echo $row;

} else {

//sql error

}
Thanks in advance