Jump to content

jackh

Members
  • Posts

    5
  • Joined

  • Last visited

Profile Information

  • Location
    UK

jackh's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Cheers, justsomeguy - got it working
  2. Hi all, I'm trying to create a query which selects fields from 2 tables. I have a table 'stock' to store cars for sale and a table called 'custstock' which has the customer username and the vehID. How do I show all the cars that relate the that user who is logged in? My current query that doesn't work; $username = "-1"; if(isset($_SESSION['username'])){ $username = $_SESSION['username']; } // executeable query $sql = ("SELECT * FROM [stock] JOIN custstock ON [stock].custstockvehID = custstock.vehID WHERE username = '$username'"); Thanks, Jack
  3. I echoed the value and still wasn't working - had a look at my query and it was because I used a capital in the name! So simple. Thanks for your help Foxy Mod!
  4. Yeah, the session is set from the login screen along with the users name which I echo on each page and works fine.
  5. Hi all, I'm trying to execute a query which uses the value from my session which is set when the user logs in. When I try to view the query, it displays nothing. SQL statement // get value of session $username = $_SESSION['username']; // executeable query $sql = ("SELECT * FROM custstock WHERE username = '$username'"); // query $row = mysqli_query($custdb, $sql) or die(mysqli_error($custdb)); The code for my table; <table width="100%" border="1" cellpadding="1" cellspacing="1" class="carInfo"> <tr> <th>ID</th> <th>Vehicle ID</th> <?php while($custveh = mysqli_fetch_assoc($row)){ echo "<tr>"; echo "<td>".$custveh['id']."</td>"; echo "<td>".$custveh['vehID']."</td>"; echo "</tr>"; } ?> </table> Any suggestions would be great, thanks! Jack
×
×
  • Create New...