onestopplay
06-30-2009, 11:30 PM
So I have a database,
id | title | approved
1 | title1 | yes
2 | title2 | yes
3 | title3 | no
Then I have this PHP script:
<?php
//opens connection to mysql server
$dbc = mysql_connect("localhost", "username", "password");
if (!$dbc)
{
die('Not connected :' . mysql_error());
}
//select database
$db_selected = mysql_select_db("mydatabase", $dbc);
if (!$db_selected)
{
die("cant connect :" . mysql_error());
}
$result = mysql_query("SELECT * FROM mytable ORDER BY title");
while($row = mysql_fetch_array($result))
{
echo "" . $row['title'] . "";
echo "<BR>";
}
mysql_close($dbc);
?>
That displays each Title. How do I make it so that only approved=yes titles show? Thanks in advanced for any help.
id | title | approved
1 | title1 | yes
2 | title2 | yes
3 | title3 | no
Then I have this PHP script:
<?php
//opens connection to mysql server
$dbc = mysql_connect("localhost", "username", "password");
if (!$dbc)
{
die('Not connected :' . mysql_error());
}
//select database
$db_selected = mysql_select_db("mydatabase", $dbc);
if (!$db_selected)
{
die("cant connect :" . mysql_error());
}
$result = mysql_query("SELECT * FROM mytable ORDER BY title");
while($row = mysql_fetch_array($result))
{
echo "" . $row['title'] . "";
echo "<BR>";
}
mysql_close($dbc);
?>
That displays each Title. How do I make it so that only approved=yes titles show? Thanks in advanced for any help.