Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show record x number of times

Status
Not open for further replies.

NickyJay

Programmer
Sep 1, 2003
217
GB
Hi all

Simple question , i hope!

I have an events database that i am producing tickets from. I want to be able to loop an event record x number of times, showing the count on each instance - i.e. ticket no. 1, 2, 3, etc. I can get the record to output the first time, but for the subsequent "tickets", i get no output but the ticket number.

My loop:
Code:
	<?php
		//set the number of columns
		$columns = 2;
		//we add this line because we need to know the number of rows
		$num_rows = 51;
		
		// changed this to a FOR loop so we can use the number of rows
		for($i = 1; $i < $num_rows; $i++)
		{		
			$row = mysql_fetch_array($getEvent_res);

				// now, output the ticket information for each ticket in the loop to 50
				?>
				<div class="ticket_container">

					<div id="ticket">
						<?php  echo "<h3>". $row['EventTitle']. " </h3>
							with 
						<h2>". $row['MediumName']."</h2>";?>
						<p><?php echo $row['EventDetails']; ?></p>
						<p>On <?php echo $row['fmt_date']; ?></p>
						<p> at <?php echo $row['fmt_time']; ?></p>
						<p class="ticket_no">ticket no: <?php echo $i; ?></p>
					</div>
				</div>
				<?php 

		}  	
				
		// now close connections to the database
		mysql_close($mysql);
	?>

please can anyone point me in the right direction, been trying all sorts of examples from the 'net for a few hours now!

Nicola
 
you are pre-setting the number of rows. if there are fewer than 51 rows in the recordset then the delta will output as 'false'.

why are you setting the number of rows as an absolute number?
 
Just move the $row = mysql_fetch_array($getEvent_res); line out of the for loop.


I'm guessing he's trying to get 50 copies of the same ticket information.

In other words 50 tickets with the same data, but different number.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
@vacunita
that does not sound very clever from a 'stock control' perspective.

but each to their own!
 
How else would you print out x number of tickets for the same event.

The only real change in the ticket, is the number (unless there are seat assignments or something of that nature).
The rest of the information should be exactly the same for all tickets.

The only real flaw is if the number "51" is being stored somewhere as the amount of tickets printed or something.
Otherwise they'll be no way of knowing how many tickets have been printed, historically speaking.





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top