as part of a CMS I'm trying to make for myself, I want to build a random quote generator where, at the same time, I can add/edit/delete quotes from a database.
To display my quotes I'm using the following code:
Code: Select all
<table width="525" border="0" cellspacing="2px" cellpadding="2px">
<?php
include ("../library/config.php");
include ("../library/opendb.php");
$query = "SELECT * FROM `pft_quotes` ORDER BY id ASC";
$result = mysql_query($query)
or die("Error in query: $query . " . mysql_error());
if(mysql_num_rows($result) > 0)
{
while($row = mysql_fetch_object($result))
{
?>
<tr>
<td width="25px" align="center" valign="top"><?php echo $row->id; ?></td>
<td width="600px" valign="top">
<div class="quote_content">
<?php echo $row->quote; ?>
</div>
<div class="quote_source">
<?php echo $row->source; ?>
</div>
<br />
</td>
</tr>
<?php
}
}
else
{
echo 'Sorry, there currently are no quotes to display. ';
}
?>
</table>If not, how would I go about producing a random quote from my above code?
Thanks very much,
Patrick