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:
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>";
}
?>
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
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
Bob
thx for your help. I needed to place a small adjustment on the $database part. It works ok now.
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>
This topic is locked and no more replies can be posted.