Its been a while since I've done database work so need a little help. After doing some Googling, I have come up with the following code which will check to see if the user has already submitted a form and if so will populate the checkboxes with the data initially submitted. (I have removed all but one CheckBox option so that the code is smaller
$Moari (the Moari field does have data in the table for the user in question) never displays any info which means that my data is not being retrieved from the database.
I have run the following SQL query directly on the database, and it workd
I'm not sure how to see what $db holds (as I don't seem able to echo it out). I am also not sure how to extract data from it, should it contain any.
<?
$user =& JFactory::getUser();
$username=($user->username);
if ($user->gid == 0) {
echo "<p>You are not authorized to view this page!</p><p>Please logon.</p>";
return;
}
$db =& JFactory::getDBO();
$db->setQuery('SELECT Art,Drama,Music,ESOL,Numeracy,Moari,French,Japanese,Literacy,Technology,FoodTechnology,Graphics FROM jos_chronoforms_form_Year8To9_options WHERE Username="'.$username.'"');
$Moari=($db->Moari);
?>
<p>
<label for="Moari">Moari</label>
<?php if ($Moari==1)
{echo "<input name='Moari' type='checkbox' id='Moari' value='1' checked='checked>'";}
else
{echo "<input name='Moari' type='checkbox' id='Moari' value='1'>";} ?>
</p>
<p>
<input type="submit" name="Submit" id="Submit" value="Submit" />
</p>
$Moari (the Moari field does have data in the table for the user in question) never displays any info which means that my data is not being retrieved from the database.
I have run the following SQL query directly on the database, and it workd
SELECT Art,Drama,Music,ESOL,Numeracy,Moari,French,Japanese,Literacy,Technology,FoodTechnology,Graphics FROM jos_chronoforms_form_Year8To9_options WHERE Username="abasel"
I'm not sure how to see what $db holds (as I don't seem able to echo it out). I am also not sure how to extract data from it, should it contain any.