Jump to content

kendris

Members
  • Posts

    19
  • Joined

  • Last visited

Posts posted by kendris

  1. 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);
  2. <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. 

  3. 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

  4.  

    The delete sql statement does not execute according your code above:

     

    What you want to say whit that one?

    if ($delete = '1' ){
    $order = mysql_query("DELETE FROM booking  WHERE bookingid ='$eventid' LIMIT 1");
    }
    

    If the form is submitted delete selected row.

  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>");
    
    
    
    
    
    
    
    
    ?>
    
    
    
    
    
    
    
    
    
    
    
    
    <?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.

  6. <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?

  7. 
    <?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.

  8. <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.

  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);
    $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>
    
    
    
    
    </tr>";
    
    
    while($row = mysql_fetch_array($result))
      {
      $eventid = $row["bookingid"];
    
    
    
    
      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"]))
    {
    
    
    $forename = $_POST["bookingid"];
    $eventname = $_POST["eventid"];
    $email = $_POST["userid"];
    
    
    
    
    }
    
    
    $order = mysql_query("DELETE FROM booking 
    
    
              WHERE bookingid ='$result2' LIMIT 1");
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
     ?> 
    
    
    </div>
    
    
    </div>
    </div>
    
    
    
    
    
    
    
    
    
    
    </html>

    I have been trying to set this so it will delete a row but for some reason it's not working.

  10.  

    <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>
    
    
    
    
    
    
    <select name="listbox" size="5" onchange>
    <?php
    
    
    $tester=mysql_query('SELECT eventname FROM event ORDER BY eventname ASC');
    while($row = mysql_fetch_array($tester))
      {
      echo "<option>" . $row['eventname'] . "</option>"  ;
    
    
      }
      ?>
    
    
    
    
    </select>
    <select name="price" size="5">
    
    
    
    
    </select>
    <select name="price" size="5">
     <?php
    
    
    $location=mysql_query('SELECT location FROM event');
    while($row = mysql_fetch_array($location))
      {
      echo "<option>" . $row['location'] . "</option>"  ;
    
    
      }
      ?>
    </div>
    </div>
    
    
    
    
    
    
    
    
    
    
    </html>
     

    Basically I'm looking for a way to make this dynamic, so if an option from the first select it will display options in a second table but for each select it will generate the correct listings.

  11. Yes sorry it should display at login.php

     

    I had been following the tutorial to the letter, currently I'm trying to find a tutorial that will show me how to register a unique user and log in, it should have some minor security so the user will only be able to see pages if logged in. Would you be able to suggest a different tutorial?

     

    The functions were put in basically because the tut told me to.

×
×
  • 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.