kendris Posted April 19, 2013 Share Posted April 19, 2013 <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. Quote Link to comment Share on other sites More sharing options...
lemmin Posted April 19, 2013 Share Posted April 19, 2013 Your loop is overwriting variables. What exactly are you trying to do? Quote Link to comment Share on other sites More sharing options...
seandisanti Posted April 19, 2013 Share Posted April 19, 2013 I've already written a response to this one at https://phpacademy.org/forum/topic/while-loop-25045 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.