Hey guys,
I’ve got a problem with my code…
The objective of this code is to show a specific data from the user in session.
But something is wrong…
Can someone help me to complete the code?
[php]$user_id = SearchUser($_SESSION[‘user’][‘id’]);
$ok = true;
//Check user function "SearchUser"
if(SearchUser($user_id)) {
$dbh = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password);
$procurarUser = $dbh->prepare("SELECT ID_Article,ID_Utilizador, Data_Compra, Price, Cred_Depois FROM reg_log ORDER BY Data_Compra WHERE id='$user_id'");
$procurarUser->execute();
$checkUser = $procurarUser->fetchAll();
foreach($checkUser as $User)
{
echo "<table>";
echo "<tr>";
echo "<td><b>Artigo</b></td>";
echo "<td><b>ID</b></td>";
echo "<td><b>Preço</b></td>";
echo "<td><b>Creditos Anteriores</b></td>";
echo "<td><b>Data & Hora</b></td>";
echo "</tr>";
echo "<br /><tr><td>" . $User['ID_Article'] . "</td><td>". $User['ID_Utilizador'] . "</td><td>" . $User['Price'] . "</td><td>". $User['Cred_Depois'] . "</td><td>" . $User['Data_Compra'] . "</td></tr> " ;
echo "</table>";
}
$ok = true;
$dbh = null; //close db
} else {
echo "You have no purchases.";
$ok = false;
}[/php]