Jump to content

Appending to Variable


savagenoob

Recommended Posts

I am trying to append data to a variable through each loop of a MySQL array, but I am doing it wrong. Is this possible? Here is the code.

$html = <<<TABLE
<table border = "1" align = "center">
TABLE;
//// Get Endorsement Info
$endo = mysql_query("SELECT * FROM endorse WHERE endonum = '$endonum' AND agency = '$agency' ORDER BY ID DESC LIMIT 1");
while($endofetch = mysql_fetch_array($endo)){
$endotype = $endofetch['type'];
$typeid = $endofetch['typeid'];
$change = $endofetch['changetype'];
$info = mysql_query("SELECT * FROM $endotype WHERE ID = '$typeid'") or die(mysql_error());
$infoout = mysql_fetch_array($info);
$date = date("m/d/Y g:i a", strtotime($endofetch['date']));
if($endotype == "drivers"){
$firstname = $infoout['firstname'];
$lastname = $infoout['lastname'];
$licnum = $infoout['driverslic'];
$vyear = $infoout['year'];
$vmake = $infoout['make'];
$vmodel = $infoout['model'];
$vvin = $infoout['year'];
$html .= <<<TABLE
<tr>
<td>Endorsement Request Date:</td><td>{$date}</td>
</tr>
<tr>
<td>Change Requested:</td><td>{$change} Driver</td>
</tr>
<tr>
<td>Driver Info:</td><td>{$firstname} {$lastname} </td>
</tr>
<tr>
<td>License Number:</td><td>{$licnum}</td>
</tr>
<tr>
<td>Signature __________________</td><td>Date:_____________</td>
</tr>
TABLE;
}
if($endotype == "vehicles"){
    if($change == "Delete"){
     $veyear = $endofetch['year'];
     $vemake = $endofetch['make'];
     $vemodel = $endofetch['model'];
     $vevin = $endofetch['vin'];
    $html .= <<<TABLE
<tr>
<td>Endorsement Request Date:</td><td>{$date}</td>
</tr>
<tr>
<td>Change Requested:</td><td>Delete Vehicle</td>
</tr>
<tr>
<td>Vehicle Info:</td>
</tr>
<tr>
<td>Year:</td><td>{$veyear}</td><td>Make:</td><td>{$vemake}</td><td>Model:</td><td>{$vemodel}</td>
</tr>
<tr>
<td>Vin Number:</td><td>{$vevin}</td>
</tr>
<tr>
<td>Signature __________________</td><td>Date:_____________</td>
</tr> 
TABLE;
    }
    else
    {
$html .= <<<TABLE
<tr>
<td>Endorsement Request Date:</td><td>{$date}</td>
</tr>
<tr>
<td>Change Requested:</td><td>{$change} Vehicle</td>
</tr>
<tr>
<td>Vehicle Info:</td>
</tr>
<tr>
<td>Year:</td><td>{$vyear}</td><td>Make:</td><td>{$vmake}</td><td>Model:</td><td>{$vmodel}</td>
</tr>

<tr>
<td>Vin Number:</td><td>{$vvin}</td>
</tr>
<tr>
<td>Signature __________________</td><td>Date:_____________</td>
</tr>
TABLE;
}
}
}
$html .= <<<TABLE
</table> 
TABLE;
echo $html;

This code is for creating a PDF  with fpdf and a third party table class. Its only displaying the last table data in the loop when I echo $html so the data is being overwritten each loop.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.