Hi everyone, my first post!
I hope you can help me I am having terrible problems solving an issue.
I am designing a website with php and mysql, it will allow a user to record their bank accounts, credit card loan details etc (dont worry its a project and not for general use so it not malicious!).
They will also be able to store their transactions, credits and debits to and from those accounts
At present the transaction database contains all the credits and debit for every account and the home page has a list of all the accounts that the customer has registered.
What I am trying to do is when the user is on the home page they click on a link for an account and this will display for them all credits and debits associated solely with that account. So lets say on the home screen there is a list:
Steve Current Account
Steve CreditCard Account
Where I to click on Steve Current Account it will then display:
Credit Debit Catagory
200 - salary
- 100 Food
etc
Apologies for this being a longwinded first post but I have been banging my head against a brick wall for two days now! It seems straightforward enough but I am very much a newbie when it comes to this. Would anyone know how to approach this or are there any videos on the site that may help.
The current code that I am using that isnt working is
<?php
//connect to database
include ('connect-To-db.php');
$id = $_GET['id'];
global $mysqli;
echo "$id";
$stmt = $mysqli->prepare("SELECT t.Credit, t.Debit, t.Catagory,a.Accname
FROM transactions as t LEFT JOIN account as a ON a.Accname=t.Accname
WHERE a.accID=?");
echo $mysqli->error;
$stmt->bind_param("i", $id);
if($stmt->execute()){
//$stmt->bind_result($cred, $deb, $cat,$Accname);
$stmt->fetch();
$stmt->store_result();
if ($stmt->num_rows>0){
//echo "Search worked";
//echo "<p><b>$Accname</b>: Credit: $cred, Debit: $deb, Category: $cat</p>";
$stmt->bind_result($cred, $deb, $cat, $Accname);
while($stmt->fetch())
{
echo "<p><b>$Accname</b>: Credit: $cred, Debit: $deb, Category: $cat</p>";
}
}
else{
echo "Search didnt work";
}
}
else {
echo "QUERY ERROR: ".$mysqli->error;
}
?>