Page 1 of 1

TCPDF and Loop

Posted: Tue Apr 12, 2011 10:47 am
by grahambucknall
Hi

I am trying to work out how to add a loop statement to my pdf generation (I think that's what I need).

I have a mysql table - events with 3 fields - id, name and date.

In my php page which is to generate the pdf I have:

mysql_select_db($database_events, $events);
$result = mysql_query("SELECT id, date, name
FROM events_pbw
WHERE id>200
");

while($row = mysql_fetch_array($result))
{
$id = $row['id'];
$date = $row['date'];
$name = $row['name'];
}


and in amongst the $html part of the page I have:

$html ="<html>

$id<br>
$name<br>
$date<br>

<i>This is a test calendar.</i>

This all works fine but (obviously) just gives one result. What do I need to add to make it list out all of the possible events?

Many thanks in advance.

Re: TCPDF and Loop

Posted: Tue Apr 12, 2011 6:30 pm
by danwguy
use a foreach loop, or echo them straight from the query after the while statement. Would be a lot easier to help if you posted up the whole page so I can see where these are and how you are implimenting them