Jump to content

SteveNI

Member
  • Posts

    7
  • Joined

  • Last visited

Everything posted by SteveNI

  1. Thanks Ben I was hoping to refrain from making the user press a submit button, I was hoping that they could could simply select an option in the dropdown menu and this would in turn would run the necessary query to produce a table. I am reading things about ajax and javascript onClick but to be honest I dont really understand what needs to be done.
  2. I hope someone can offer me some guidance I am looking to populate a dropdown box with values from a database column Then when the user selects one of the dropdown options it then runs a second query that will produce a results table. I have my code to populate the dropdown <?php include ('connect-To-db.php'); $query = $mysqli->query("Select distinct`catagory` FROM `transactions` WHERE `Debit`!=0"); echo"<select name = 'catagory'>"; while ($row = $query->fetch_object()){ echo "<option value= '".$row->catagory."'>".$row->catagory."</option>"; } echo "</select>"; ?> And I also have my code that will query the database to produce the results I need <?php include ('connect-To-db.php'); if($query = $mysqli->query("Select `ThirdParty`,`Debit`,`Date` FROM `transactions` WHERE `Catagory` = 'shopping'")){ if($query->num_rows>0){ echo"<table border ='1' cellpadding='10'>"; echo "<tr><th>Payee</th><th>Amount</th><th>Date</th></tr>"; while($row=$query->fetch_object()){ echo "<tr>"; echo "<td>".$row->ThirdParty."</td>"; echo "<td>".$row->Debit."</td>"; echo "<td>".$row->Date."</td>"; echo "</tr>"; } echo "</table>"; } else{ echo 'No results to return'; } } else{ echo 'ERROR'.$mysqli->error; } ?>[code] What I dont quite understand is what I need to do to get the two pieces of code to run together. Can anyone point me in the right direction?
  3. I have moved the include line below my variables in login.php but I am still getting the Notice: undefined variable: error in ...v_login.php on line 18 Its very frustrating lol!
  4. Here is my code, I'm taking things a little bit further than you and see this as a registration of a user where we take name, username, password, email etc from the user. Though I should imagine this is the same principle as what you are doing. Here is my v_login <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Registration</title> <link href="style.css" media="screen" rel="stylesheet" type="text/css"/> </head> <body> <h1>Register</h1> <div id="content"> <form action="" method="post"> <div> <?php if($error['alert']!='') echo "<div class='alert'>".$error['alert']."</div>"?> <label for="firstname">First Name: * </label> <input type="text" name="firstname" value="<?php echo $input['first'];?>"> <div class ="error"><?php echo $error['first'];?></div> <label for="lastname">Second Name: * </label> <input type="text" name="lastname" value="<?php echo $input['last'];?>"> <div class ="error"><?php echo $error['last'];?></div> <label for="username">Username: * </label> <input type="text" name="username" value="<?php echo $input['user'];?>"> <div class ="error"><?php echo $error['user'];?></div> <label for="password">Password: * </label> <input type="text" name="password" value="<?php echo $input['pass'];?>"> <div class ="error"><?php echo $error['pass'];?></div> <label for="password2">Re-Confirm Password: * </label> <input type="text" name="password2" value="<?php echo $input['pass2'];?>"> <div class ="error"><?php echo $error['pass2'];?></div> <label for="email">Email: * </label> <input type="text" name="email" value="<?php echo $input['em'];?>"> <div class ="error"><?php echo $error['em'];?></div> <p class="required">Required Fields</p> <input type="submit" name="submit" class="submit" value="Submit"> </div> </form> </div> <?php ?> </body> </html> Then I have started to create my login.php script as you did, I have echoed what you have done creating input and error variables, though obviously I have more as i have more fields. This is as far as I have got in your tutorial and when you test the code all your errors have disappeared <?php //Start session session_start(); include('config.php'); include('connect-To-db.php'); include('v_login.php'); $error ['alert'] = ''; $error ['first'] = ''; $error ['last'] = ''; $error ['user'] = ''; $error ['pass'] = ''; $error ['pass2'] = ''; $error ['em'] = ''; $input ['first'] = ''; $input ['last'] = ''; $input ['user'] = ''; $input ['pass'] = ''; $input ['pass2'] = ''; $input ['em'] = ''; ?>
  5. Hi Ben Its the non OOP one Its the Simple PHP Log in system, with 18 videos on it.
  6. I wonder if someone can help me. I am following Bens tutorials on building a simple log in system. I am on the third video and so far I believe I've followed it line by line. At point 5.30 seconds he refreshes the login page and all the previous errors he had all disappeared, however when I enter the same code I still have the error Notice: undefined variable: error in ...v_login.php on line 18 Like I said I was sure I had followed Ben to the letter, I cannot see where $error is defined in the v_login script, however it seems to work in Bens code. What could I be doing wrong?
  7. 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; } ?>
×
×
  • Create New...