Buy Now
Sign in

Problems displaying capured data

luykmhm , January 18 2008, 05:29
L
luykmhm 12
January 18 2008, 05:29 #5013
I created a form where members can subscribe for a information meeting. The form works ok. I would like to display the subscription for an individual logged in user. I tried several things but i can't get it to work. Can you give me a hand??

The form code I produces so far is:

<?php
// initialise the Joomla database code
$database =& JFactory::getDBO();
$email = "$user = &JFactory::getUser();echo $user->email;"

// set up the database query
$sql = "SELECT * FROM #__chronoforms_3 WHERE email=CONCAT("'",$email,"'"«») order by Naam,recordtime DESC ;";
$database->setQuery($sql);

// retrieve the data from the database
$rows = $database->loadObjectList();
?>

<table>
<?php
echo "<table><tr>
<td>Naam</td>
<td>Datum aanmelding</td>
<td>Emailadres</td>
<td>Aantal personen</td></tr>";
foreach ( $rows as $record ) {
echo "<tr><td>".$record->Naam."</td>
<td>".$record->recordtime."</td>
<td>".$record->email."</td>
<td>".$record->aant_pers."</td></tr>";
}
?>
GreyHead 64
January 18 2008, 15:59 #5023
Hi luykmhm,

The end part of your code looks OK but the $email looks odd (maybe I just don't understand). Taking it step by step try this
<?php
global $database;

$user = &JFactory::getUser();
// You may want to add a check here to see if the user is logged in
$email = $user->email;

// set up the database query
$sql = "
SELECT *
FROM #__chronoforms_3
WHERE email='$email'
ORDER BY Naam, recordtime DESC;";

$database->setQuery($sql);

// Get the data
$rows = $database->loadObjectList();
?>
Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
L
luykmhm 12
January 18 2008, 19:20 #5030
Bob

thx for your help. I needed to place a small adjustment on the $database part. It works ok now.

<?php
// initialise the Joomla database code
$database =& JFactory::getDBO();

$user = &JFactory::getUser();
$email = $user->email;

// set up the database query
$sql = "SELECT * FROM #__chronoforms_3 WHERE email='$email' order by Naam,recordtime DESC ;";
$database->setQuery($sql);

// retrieve the data from the database
$rows = $database->loadObjectList();
?>

<table>
<?php
echo "<table><tr>
<td>Naam</td>
<td>Datum aanmelding</td>
<td>Emailadres</td>
<td>Aantal personen</td></tr>";
foreach ( $rows as $record ) {
echo "<tr><td>".$record->Naam."</td>
<td>".$record->recordtime."</td>
<td>".$record->email."</td>
<td>".$record->aant_pers."</td></tr>";
}
?>
</table>