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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem somewhere - display sessions 1

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
I had this all working at one stage, now it's got a problem. I can put test in the sections <------->, but it throws an error saying missing a , or an ; if I try putting in a session variable:

echo'<td width="15%" align="left"><b><font size="2"><?=$_SESSION['QTY'][$i]?></font></b></td>';


Code:
<?
echo '<table border="1" width="70%" bordercolor="#000000" cellspacing="0"><b><font face="Arial">';
// BETACAM SP ONLY ----------------------------------------------------------------------------------------------
//If Betacam SP Ordered then put in titles & Headings
if ($_SESSION['RTL'][14]>0) {
//Title
echo'<td width="95%" align="left" colspan="5">Fuji M321 Betacam SP</td></tr>';
//Headings
echo'<tr><td width="25%" align="center"><b><font face="Arial" size="2">Item</font></b></td>';
echo'<td width="25%" align="center"><b><font face="Arial" size="2">Duration</font></b></td>';
echo'<td width="15%" align="center"><b><font face="Arial" size="2">Quantity</font></b></td>';
echo'<td width="15%"><b><font face="Arial" size="2">Unit Price</font></b></td>';
echo'<td width="15%" align="left"><b><font face="Arial" size="2">Sub Total</font></b></td></tr>';
}

//If Betacam SP ordered then put in table
// Betacam SP
for ($i=9;$i<15;$i++)
if ($_SESSION['QTY'][$i]>0) {
//Items
echo'<tr><td width="25%" align="center"><b><font size="2">----------</font></b></td>';
echo'<td width="25%" align="center"><b><font size="2">-----------</font></b></td>';
echo'<td width="15%" align="left"><b><font size="2">------------</font></b></td>';
echo'<td width="15%"><b><font size="2">------------</font></b></td>';
echo'<td width="15%"><b><font size="2">------------</font></b></td></tr>';
}

echo'<table border="1" width="75%" id="table1" bordercolor="#000000" cellspacing="0"><tr>';
echo'</table>';
echo'&nbsp';
echo'&nbsp';
echo'&nbsp';

?>
 
your syntax is way wrong here
Code:
echo'<td width="15%" align="left"><b><font size="2"><?=$_SESSION['QTY'][$i]?></font></b></td>';

why are you using php tags in a string?

Code:
echo'<td width="15%" align="left"><b><font size="2">'. $_SESSION['QTY'][$i].'</font></b></td>';
 
Thanks, goofed on that one well and truly. Won't do that again.
 
it comes down to horses for courses/personal preferences:
lots of people do:
Code:
$str = 'in single quotes with "quoted" bits and variables '.$var;
or
Code:
while($row=mysql_fetch_assoc($result):
?>
<tr><td><?=$row['val1']</td><td>$row['val2']</td></tr>
<? endwhile;
or
Code:
echo "<tr><td>a singlequoted  thing '{$row['val1']}'</td><td>{$row['val2']}</td></tr>";
or
Code:
echo <<<STR
<tr><td>a singlequoted  thing '{$row['val1']}'</td><td>{$row['val2']}</td></tr>

STR;

it's clear that there is a marginal speed advantage in the 1st solution. however given the usual inefficiency of my code my preference is the last syntax for anything more than a few lines of html. or when templating is desired to use type 2. i'd guess you started with type 2 and then read somewhere that single quotes were better...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top