Jump to content

kendris

Members
  • Posts

    19
  • Joined

  • Last visited

kendris's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm an idiot it was... SELECT IFNULL(trans, 0) AS 'Transactions', customer.cID AS 'Customer ID' FROM customer LEFT JOIN account ON (account.cID = customer.cID) WHERE account.trans IS NULL;
  2. I'm trying to display the null values only, where am I going wrong? SELECT IFNULL(trans, 0) AS 'Transactions', customer.cID AS 'Customer ID', customer.surname AS 'Surname' FROM customer LEFT JOIN account ON (account.cID = customer.cID) WHERE IFNULL(trans, 0);
  3. Yes, I know unfortunately it has to be done with 100% abstraction
  4. I'm trying to get validation messages to display on the same page as my login form without any PHP within my login page, is that possible?
  5. <html> <?php include "overallheader.php" ?> <div id ='container'> <div id ='content'> <div id='navBar'> <?php include "navbar.php"?> </div> <div id='userinfo'> <?php session_start(); if (isset($_SESSION["username"])) { $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); mysql_close($con); } else die("You must be logged in <a href='index.php'>Back</a>"); $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); $result=mysql_query('SELECT eventname FROM event'); $result = mysql_query("SELECT * FROM event"); ?> </div> <div id ="eventform"> <?php $result = mysql_query("SELECT * FROM event ORDER BY `eventname` ASC"); while($row = mysql_fetch_array($result)) { $eventid = NULL; $iduser = NULL; $eventid = $row["eventid"]; $result2 = mysql_query('SELECT userid FROM users WHERE username="'.$_SESSION["username"].'"'); while($row = mysql_fetch_array($result2)) { $iduser= $row["userid"]; } if (isset($_GET["eventid"],$_GET["eventname"],$_GET["price"],$_GET["location"], $_GET["user"])) { $eventid = $_GET["eventid"]; $eventname = $_GET["eventname"]; $price = $_GET["price"]; $location = $_GET["location"]; $iduser = $_GET["user"]; } } { $queryreg = mysql_query(" INSERT INTO booking VALUES ('', '$eventid', '$iduser') "); } echo "Your event has been booked"; header("Refresh: 1; url=member.php"); ?> </div> </div> </div> </html> I thought I had sorted this but it seems only to insert the last entry of the while loop, I'm looking for a tutorial that will help me sort the problem. It should insert each selected row.
  6. kendris

    delete

    echo "<table border='1'> <tr> <th>Booking ID</th> <th>Event ID</th> <th> User ID</th> <th> Delete</th> </tr>"; while($row = mysql_fetch_array($result)) { $eventid = $row["bookingid"]; $order = mysql_query("DELETE FROM booking WHERE bookingid ='$eventid' LIMIT 1"); "<form name='myForm' action ='' onsubmit='return validateForm()' method='POST'>"; echo "<tr>"; echo "<td>" . $row["bookingid"] . "</td>"; echo "<td>" . $row["eventid"] . "</td>"; ?> <td ><input type='text' name='eventid' id='eventid' value='<?php echo "$eventid" ; ?>' readonly='readonly' /> </td> <?php echo '<td> <INPUT TYPE="submit" VALUE="Delete"></td>'; echo "</tr>"; echo "</form>"; } echo "</table>"; This is the form section
  7. kendris

    delete

    If the form is submitted delete selected row.
  8. kendris

    delete

    <html> <?php include "overallheader.php" ?> <div id ='container'> <div id ='content'> <div id='navBar'> <?php include "navbar.php"?> </div> <div id='userinfo'> <?php session_start(); if (isset($_SESSION["username"])) { $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); mysql_close($con); } else die("You must be logged in <a href='index.php'>Back</a>"); ?> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); ?> </div> <div id ="eventform"> <?php $result2 = mysql_query("SELECT bookingid FROM booking"); $result = mysql_query("SELECT * FROM booking"); echo "<table border='1'> <tr> <th>Booking ID</th> <th>Event ID</th> <th> User ID</th> <th> Delete</th> </tr>"; while($row = mysql_fetch_array($result)) { $eventid = $row["bookingid"]; $order = mysql_query("DELETE FROM booking WHERE bookingid ='$eventid' LIMIT 1"); "<form name='myForm' action ='' onsubmit='return validateForm()' method='POST'>"; echo "<tr>"; echo "<td>" . $row["bookingid"] . "</td>"; echo "<td>" . $row["eventid"] . "</td>"; ?> <td ><input type='text' name='eventid' id='eventid' value='<?php echo "$eventid" ; ?>' readonly='readonly' /> </td> <?php echo '<td> <INPUT TYPE="submit" VALUE="Delete"></td>'; echo "</tr>"; echo "</form>"; } echo "</table>"; if ($delete = '1' ){ $order = mysql_query("DELETE FROM booking WHERE bookingid ='$eventid' LIMIT 1"); } /* if (isset($_POST["bookingid"], $_POST["eventid"], $_POST["userid"])) { $booking = $_POST["bookingid"]; $eventid = $_POST["eventid"]; $userid = $_POST["userid"]; echo "Order has been deleted"; } */ ?> </div> </div> </div> </html> I tried like this but same thing.
  9. <html> <?php include "overallheader.php" ?> <div id ='container'> <div id ='content'> <div id='navBar'> <?php include "navbar.php"?> </div> <div id='userinfo'> <?php session_start(); if (isset($_SESSION["username"])) { $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); mysql_close($con); } else die("You must be logged in <a href='index.php'>Back</a>"); ?> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); ?> </div> <div id ="eventform"> <?php $result5 = mysql_query('SELECT userid FROM users WHERE username="'.$_SESSION['username'].'"'); while ($row = mysql_fetch_assoc($result5)) { $user = $row['userid']; } $result = mysql_query("SELECT * FROM users"); while($row = mysql_fetch_assoc($result)) { $result2 = mysql_query('SELECT forename FROM users WHERE username="'.$_SESSION['username'].'"'); $result3 = mysql_query('SELECT surname FROM users WHERE username="'.$_SESSION['username'].'"'); $result4 = mysql_query('SELECT email FROM users WHERE username="'.$_SESSION['username'].'"'); while($row = mysql_fetch_assoc($result2)) { $forename = $row["forename"]; } while($row = mysql_fetch_assoc($result3)) { $surname = $row["surname"]; } while($row = mysql_fetch_assoc($result4)) { $email = $row["email"]; } } if (isset($_POST["forename"], $_POST["surname"], $_POST["email"])) { $forename = $_POST["forename"]; $eventname = $_POST["surname"]; $email = $_POST["email"]; } $sql = mysql_query ("UPDATE `users` SET `forename` = '$forename',`surname` = '$surname',`email` = '$email' WHERE `users`.`userid` = '$user' LIMIT 1"); ?> <form name='myForm' action ='edit.php' onsubmit='return validateForm()' method='POST'> <table> <tr><td ><input type='text' name='forename' value='<?php echo "$forename"; ?>' /> </td> </tr> <tr><td ><input type='text' name='surname' value='<?php echo "$surname"; ?>' /> </td> </tr> <tr><td ><input type='text' name='email' value='<?php echo "$email"; ?>' /> </td> </tr> <td> <INPUT TYPE="submit" VALUE="Edit"></td> </form> </table> </div> </div> </div> </html> That sort of idea?
  10. kendris

    delete

    I attempted it a few different ways with more or less the same result
  11. He wanted a login code, he can tweak it to fit his needs.
  12. <?php session_start(); $username = $_POST['username']; $password = $_POST['password']; if ($username&&$password) { $connect = mysql_connect("localhost","root","") or die ("Could not connect"); mysql_select_db ("login") or die ("Could not find database"); $query = mysql_query("SELECT * FROM users WHERE username ='$username'"); $numrows = mysql_num_rows($query); if ($numrows !=0) { while ($row =mysql_fetch_assoc($query)) { $dbusername = $row['username']; $dbpassword = $row['password']; } if ($username==$dbusername&&md5($password)==$dbpassword) { echo header( 'Location: member.php' ) ; $_SESSION['username']=$dbusername; } else echo "Inncorrect password"; } else die("That user dosen't exist"); } else die("Please enter a username and a password"); ?> It's not great but it works.
  13. kendris

    delete

    <html> <?php include "overallheader.php" ?> <div id ='container'> <div id ='content'> <div id='navBar'> <?php include "navbar.php"?> </div> <div id='userinfo'> <?php session_start(); if (isset($_SESSION["username"])) { $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); mysql_close($con); } else die("You must be logged in <a href='index.php'>Back</a>"); ?> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("login", $con); $result=mysql_query('SELECT eventname FROM event'); $result = mysql_query("SELECT * FROM event"); ?> </div> <div id ="eventform"> <?php $result = mysql_query("SELECT * FROM booking"); $result2 = mysql_query("SELECT bookingid FROM booking"); echo "<table border='1'> <tr> <th>Booking ID</th> <th>Event ID</th> <th> User ID</th> <th> Delete</th> </tr>"; while($row = mysql_fetch_array($result)) { $eventid = $row["bookingid"]; "<form name='myForm' action ='' onsubmit='return validateForm()' method='POST'>"; echo "<tr>"; echo "<td>" . $row["bookingid"] . "</td>"; echo "<td>" . $row["eventid"] . "</td>"; ?> <td ><input type='text' name='eventid' id='eventid' value='<?php echo "$eventid" ; ?>' readonly='readonly' /> </td> <?php echo '<td> <INPUT TYPE="submit" VALUE="Delete"></td>'; echo "</tr>"; echo "</form>"; } echo "</table>"; if (isset($_POST["bookingid"], $_POST["eventid"], $_POST["userid"])) { $booking = $_POST["bookingid"]; $eventid = $_POST["eventid"]; $userid = $_POST["userid"]; } $order = mysql_query("DELETE FROM booking WHERE bookingid ='$eventid' LIMIT 1"); ?> </div> </div> </div> </html> I manage to get it to delete each row but it seems to do it each page refresh.
  14. kendris

    delete

    No errors, it's giving no fed back.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.