I'm trying a simple query to get students that signed up for each possible matching class, and I'm getting a weird result with this,when I print out. If they've signed up a student in one class, and a student in another class, I get the two students printing out fine. But, let's say they put TWO students in one class, and one student in the second class. In printing the second class result, it loops through the first class enrollees before giving me the name I want, like this :

workshop1 - tyson chandler
workshop1 - alton thurst

workshop1 - tyson chandler
workshop1 - alton thurst
workshop2 - Judi dench


On the first page I make a session variable of an array of data, to be used on page two:

<?php session_start(); 
$wid = $_POST['wid']; 
//wid is an array
$_SESSION['workshops']=$wid;

<form method="post" action="register5b.php" target="_blank">
    <input type="hidden" name="rid" value="<?= $rid ?>" />
    <input type="hidden" value="<?= $wid ?>" name="wid" />
<input type="submit" value="print for my records" />
       </form>

On the previous page I print_r'd to see I have my registration id, and the attendee numbers are in an array as Array ( [0] => 215 [1] => 215 [2] => 216 )
Then on page two, where my results are printing screwy, I get:

<?php

	foreach($_SESSION['workshops'] as $key=>$value)
    {
	
	$query2 = mysql_query("SELECT tbl_attendees.attendee_fname, tbl_attendees.attendee_lname FROM tbl_attendees
WHERE tbl_attendees.workshop_id = $value AND tbl_attendees.attendee_registrationid = $rid");
	
	    while ($row2 = mysql_fetch_array($query2)) {

	    echo "workshop ".$row2['workshop_id']." - ".$row2['attendee_fname']." &nbsp;". $row2['attendee_lname']."<br>";
    // and print out the values
	    }

    }
    ?>

$_SESSION worshops will have 2 instances of what you are looking up in the database. so you are instigating two echo's

Member Avatar for diafol

This was posted a year ago, so I doubt the OP still requires help. May possibly help somebody else with the same problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.