TCPDF and Loop

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
grahambucknall
Forum Newbie
Posts: 6
Joined: Thu Feb 24, 2011 8:05 am

TCPDF and Loop

Post 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.
danwguy
Forum Contributor
Posts: 256
Joined: Wed Nov 17, 2010 1:09 pm
Location: San Diego, CA

Re: TCPDF and Loop

Post 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
Post Reply