# Big Confusing PHP problem

**URL:** <https://forum.kirupa.com/t/big-confusing-php-problem/227271>\
**Category:** programming\
**Created:** [May 29, 2007, 3:09am UTC](https://forum.kirupa.com/t/big-confusing-php-problem/227271 "2007-05-29T03:09:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flash\_Man1](https://avatars.discourse-cdn.com/v4/letter/f/8797f3/32.png) [@Flash\_Man1](https://forum.kirupa.com/u/Flash_Man1)\
**Post date:** [May 29, 2007, 3:09am UTC](https://forum.kirupa.com/t/big-confusing-php-problem/227271/1 "2007-05-29T03:09:29Z")

</div>

Hey all,

this is a big annoying confusing problem…so lets start:

First off i have a mysql query which displays 20 random words in a table.  
The words are contained in the variable $r[‘words’] words being my table column in the database.

So what i want to do now is capture those exact 20 random words in a variable and send that variable with those 20 words to another php page.

On this php page i create a pdf using php which works fine and if i type a just normal text it shows in the pdf…but rather than typing normal text i want the variable and the 20 words to display in the pdf.

if anybody has any ideas on how to get my 20 words into a variable and into the other page i should be able to handle the rest.

I’ll post some code below aswell:  
The first page php code and mysqlquery:

```php

<?php require_once('Connections/myconnection.php'); ?>
<?php
$sql = mysql_query("SELECT * FROM mytable ORDER BY RAND() LIMIT 20") or die(mysql_error());
echo '<table width="466" height="256" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
    <tr>';
for($x=0; $r = mysql_fetch_assoc($sql); $x++){
    if($x == 4){
        echo '</tr><tr>';
        $x=0;
    }

    echo '<td width="116.5" height="30" align="center" class="style2">'.$r['words'].'</td>'."
";
}
echo '</tr>
</table>';
?>

```

that puts the query and the 20 words into a table

now is the pdf creating php page:

```php

<?php
include('class.ezpdf.php'); 
 
switch ($_GET['type']) 
{ 
default : $pdf = new backgroundPDF('a4', 'portrait', 'image', array('img' => 'pdfbg.jpg')); break; 
case '1' : $pdf = new backgroundPDF('a4', 'portrait', 'colour', array('r' => 0.5, 'g' => 0.4, 'b' => 0.8)); break; 
} 
 
$pdf->selectFont('Helvetica.afm'); 
$pdf->ezText('this is the normal text i want to replace with my variable', 50); 

$pdf->ezStream();

?>

```

So any ideas??

Thanks in advance 🙂
