Jump to content

while and insert


kendris
 Share

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

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