$totalRecs = 0; $link = mysql_connect('littlerh.dot5hostingmysql.com', 'littlerh_user', 'eggfarm2k'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('littlerh_db') or die('Could not select database'); //$query = 'SELECT Title FROM Recipes WHERE Ingred IS Not Null'; //$result = mysql_query($query) or die('Query failed: ' . mysql_error()); //$recCount = mysql_num_rows($result); //echo $recCount; $randNumber = rand(1, $recCount); //$randNumber = rand(1, 2); //echo $randNumber; if ($_REQUEST['Category'] != "") { $query = 'SELECT ID,Title,TitleDesc FROM Recipes WHERE Category =\''.$_REQUEST['Category'].'\''; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "
';
}
while ($line = mysql_fetch_array($result, MYSQL_ASSOC))
{
$totalRecs = 0;
foreach ($line as $col_value)
{
if ($totalRecs == 0)
{
echo "$col_value ";
}
if ($totalRecs == 1)
{
if ($_REQUEST['Print'] != "1")
{
echo $col_value." Print Recipe \n"; } else { echo $col_value." \n"; } } if ($totalRecs == 2) { $ingredients = $col_value; $ingredients = str_replace("\n\r", " ", $ingredients); $ingredients = str_replace("\n", " ", $ingredients); $ingredients = str_replace("\r ", " ", $ingredients); $ingredients = str_replace("\r", " ", $ingredients); echo " INGREDIENTS ", $instructions); $instructions = str_replace("\n", " ", $instructions); $instructions = str_replace("\r ", " ", $instructions); $instructions = str_replace("\r", " ", $instructions); echo " INSTRUCTIONS PREP TIME: $col_value "; } if ($totalRecs == 5) { echo "COOK TIME: $col_value "; } if ($totalRecs == 6) { echo "SERVES: $col_value \n"; } if ($totalRecs == 7) { echo "AUTHOR: $col_value \n"; } $totalRecs++; } } if ($_REQUEST['Print'] == "1") { echo ' |
Recipe Dowloaded From http://'.$_SERVER["SERVER_NAME"]; echo ' |