Blinger
27-06-2012, 12:25 AM
Hey everyone.
I'm having problems with my scrappy code. It only serves as a purpose to show me the recipes that I have acquired.. Only problem is it is showing just the first ingredient.. Doesn't even show me the name of the recipe??
Here's the code I have written up:
<?php
$recipe = "Coffee and Date Dough"; // this isn't normally hard coded..
echo('<table width="25%" border="1">');
// This basically gets all of the recipe into an array
$query = mysql_query("SELECT * FROM recipe WHERE recipe='{$recipe}'");
$count = 1;
while($row = mysql_fetch_array($query)){
// Couldn't think of a better way to count to 18 without using something like this.
$ing = "ing".$count;
$per = "per".$count;
// Echo out the table information
echo("<tr><td>$row[$ing]</td><td>$row[$per]</td></tr>");
$count++;
}
echo("</table>");
?>
and here is a sample sql
CREATE TABLE IF NOT EXISTS `recipe` (
`recipe` text NOT NULL,
`ing1` text NOT NULL,
`per1` float NOT NULL,
`ing2` text NOT NULL,
`per2` float NOT NULL,
`ing3` text NOT NULL,
`per3` float NOT NULL,
`ing4` text NOT NULL,
`per4` float NOT NULL,
`ing5` text NOT NULL,
`per5` float NOT NULL,
`ing6` text NOT NULL,
`per6` float NOT NULL,
`ing7` text NOT NULL,
`per7` float NOT NULL,
`ing8` text NOT NULL,
`per8` float NOT NULL,
`ing9` text NOT NULL,
`per9` float NOT NULL,
`ing10` text NOT NULL,
`per10` float NOT NULL,
`ing11` text NOT NULL,
`per11` float NOT NULL,
`ing12` text NOT NULL,
`per12` float NOT NULL,
`ing13` text NOT NULL,
`per13` float NOT NULL,
`ing14` text NOT NULL,
`per14` float NOT NULL,
`ing15` text NOT NULL,
`per15` float NOT NULL,
`ing16` text NOT NULL,
`per16` float NOT NULL,
`ing17` text NOT NULL,
`per17` float NOT NULL,
`ing18` text NOT NULL,
`per18` float NOT NULL,
`eyf` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `recipe`
--
INSERT INTO `recipe` (`recipe`, `ing1`, `per1`, `ing2`, `per2`, `ing3`, `per3`, `ing4`, `per4`, `ing5`, `per5`, `ing6`, `per6`, `ing7`, `per7`, `ing8`, `per8`, `ing9`, `per9`, `ing10`, `per10`, `ing11`, `per11`, `ing12`, `per12`, `ing13`, `per13`, `ing14`, `per14`, `ing15`, `per15`, `ing16`, `per16`, `ing17`, `per17`, `ing18`, `per18`, `eyf`) VALUES
('Coffee and Date Dough', 'Bakers Flour', 100, 'Salt', 2, 'Improver', 1, 'Gluten', 6, 'Coffee (Kularome)', 6, 'Yeast', 6, 'Water (approximately)', 60, 'Sultanas (Conditioned)', 20, 'Dates (Inspected)', 50, 'Total Weight:', 0, 'E.Y.F.', 2.51, 'Notes:', 0, 'Hey!', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '');
@robbie! ?
I'm having problems with my scrappy code. It only serves as a purpose to show me the recipes that I have acquired.. Only problem is it is showing just the first ingredient.. Doesn't even show me the name of the recipe??
Here's the code I have written up:
<?php
$recipe = "Coffee and Date Dough"; // this isn't normally hard coded..
echo('<table width="25%" border="1">');
// This basically gets all of the recipe into an array
$query = mysql_query("SELECT * FROM recipe WHERE recipe='{$recipe}'");
$count = 1;
while($row = mysql_fetch_array($query)){
// Couldn't think of a better way to count to 18 without using something like this.
$ing = "ing".$count;
$per = "per".$count;
// Echo out the table information
echo("<tr><td>$row[$ing]</td><td>$row[$per]</td></tr>");
$count++;
}
echo("</table>");
?>
and here is a sample sql
CREATE TABLE IF NOT EXISTS `recipe` (
`recipe` text NOT NULL,
`ing1` text NOT NULL,
`per1` float NOT NULL,
`ing2` text NOT NULL,
`per2` float NOT NULL,
`ing3` text NOT NULL,
`per3` float NOT NULL,
`ing4` text NOT NULL,
`per4` float NOT NULL,
`ing5` text NOT NULL,
`per5` float NOT NULL,
`ing6` text NOT NULL,
`per6` float NOT NULL,
`ing7` text NOT NULL,
`per7` float NOT NULL,
`ing8` text NOT NULL,
`per8` float NOT NULL,
`ing9` text NOT NULL,
`per9` float NOT NULL,
`ing10` text NOT NULL,
`per10` float NOT NULL,
`ing11` text NOT NULL,
`per11` float NOT NULL,
`ing12` text NOT NULL,
`per12` float NOT NULL,
`ing13` text NOT NULL,
`per13` float NOT NULL,
`ing14` text NOT NULL,
`per14` float NOT NULL,
`ing15` text NOT NULL,
`per15` float NOT NULL,
`ing16` text NOT NULL,
`per16` float NOT NULL,
`ing17` text NOT NULL,
`per17` float NOT NULL,
`ing18` text NOT NULL,
`per18` float NOT NULL,
`eyf` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Dumping data for table `recipe`
--
INSERT INTO `recipe` (`recipe`, `ing1`, `per1`, `ing2`, `per2`, `ing3`, `per3`, `ing4`, `per4`, `ing5`, `per5`, `ing6`, `per6`, `ing7`, `per7`, `ing8`, `per8`, `ing9`, `per9`, `ing10`, `per10`, `ing11`, `per11`, `ing12`, `per12`, `ing13`, `per13`, `ing14`, `per14`, `ing15`, `per15`, `ing16`, `per16`, `ing17`, `per17`, `ing18`, `per18`, `eyf`) VALUES
('Coffee and Date Dough', 'Bakers Flour', 100, 'Salt', 2, 'Improver', 1, 'Gluten', 6, 'Coffee (Kularome)', 6, 'Yeast', 6, 'Water (approximately)', 60, 'Sultanas (Conditioned)', 20, 'Dates (Inspected)', 50, 'Total Weight:', 0, 'E.Y.F.', 2.51, 'Notes:', 0, 'Hey!', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '');
@robbie! ?