Jump to content

Snodge

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Snodge

  1. I can't figure out why this isn't working. Any help is appreciated. $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT id, username FROM usermanagement"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "id: " . $row["id"]. " - Name: " . $row["username"]. " " . $row["lastname"]. "<br>"; } } else { echo "0 results"; } $username = $row["username"]; $sql2 = "SELECT slot_id FROM booking_reservation where reservation_name = $username"; $result2 = $conn->query($sql2); if ($result2->num_rows > 0) { // output data of each row while($row2 = $result2->fetch_assoc()) { echo "Name: " . $row2["slot_id"]. "<br>"; } } else { echo "0 results"; } $sql1 = "SELECT * FROM booking_slots WHERE slot_id = $row2[slot_id]"; $result1 = $conn->query($sql1); if ($result1->num_rows > 0) { // output data of each row while($row1 = $result1->fetch_assoc()) { echo "id: " . $row1["slot_id"]. " - Date: " . $row1["slot_date"]. " " . $row["username"]. "<br>"; } } else { echo "0 results"; }
×
×
  • 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.