Need Help with PHP inside an Article

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
Plaidfox
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Fri Feb 08, 2008 5:17 pm

Need Help with PHP inside an Article

Post by Plaidfox » Mon Mar 03, 2008 4:51 pm

I could really use some help. I haven't really worked with PHP for about a year, and I'm still learning joomla. I have joomla 1.5 and I installed the IncludePHP plug-in. What I'm trying to do is pull information from my database onto an article. My code so far is:

{php} defined('_JEXEC') or die('Restricted access');

$db = &JFactory::getDBO();
$num = 1;
$db->setQuery( 'SELECT title FROM #__recipe WHERE id = 1' );
$row = $db->loadResult();
echo $row;
echo "<br />";

$db->setQuery( 'SELECT ingredients FROM #__recipe WHERE id = 1' );
$row = $db->loadResult();
echo $row;
echo "<br />";

$db->setQuery( 'SELECT directions FROM #__recipe WHERE id = 1' );
$row = $db->loadResult();
echo $row;
echo "<br />";

{/php}

I got the information on how to pull individual information from the database through the tutorial:
http://dev.joomla.org/component/option, ... ase_part1/

However, I will not be the one who adds new information to the database. How do I set this up so that it finds out how many entries there are and will echo all of them out onto the article page?

Post Reply