Forum Moderators: coopster
Here is part of the script:
while($row=mysql_fetch_array($result))
{
//the format is $variable = $r["nameofmysqlcolumn"];
//modify these to match your mysql table columns
$DED=$row["DED"];
$IP=$row["IP"];
$Colo=$row["Colo"];
$Company=$row["Company"];
$Owner=$row["Owner"];
$Email=$row["Email"];
$Phone=$row["Phone"];
$location=$row["Location"];
$Switch=$row["Switch"];
$combo=$row["combination"];
$Form=$row["Formfactor"];
$userpass=$row["userpass"];
$other=$row["otherlabel"];
$notes=$row["Notes"];
echo '<html>
<body bgcolor="#AAAAAA">
<TABLE width="100%" height="100%" border="0">
<tr width="100%" height="10%">
<td align="center" valign="center" width="90%">
<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0><TR><TD><TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=2>
<TR>
<TD ALIGN="right">DED:</TD>
<TD COLSPAN=3 BGCOLOR="#ffffff">
<? echo $DED;?>
</TD>
</TR>
<TR>
<TD ALIGN="right">IP</TD>
<TD COLSPAN=5 BGCOLOR="#ffffff"><?echo $IP;?></TD>
</td>
</TR>
</tr>
</table></table>
</body>
</html>';
}
If I echo the varaible anywhere outside ot the table they work. Not sure whats going on here
It is because your syntax isn't correct. Since you are surrounding the entire string with single quotes (') everything is being sent to the browser as a string literal, including the 'variables' that you have in the string. In order to do this, you should be surrounding the string with double quotes (") and removing the excess PHP code that you have added.
Instead of adding the double quotes, though, I'm going to use a special syntax called Heredoc to make things a little easier, otherwise I'd have to add slashes before all of your double quotes in the string so that they don't terminate the string prematurely. So Heredoc syntax looks like the following:
echo <<<HTML
<html>
<body bgcolor="#AAAAAA">
<TABLE width="100%" height="100%" border="0">
<tr width="100%" height="10%">
<td align="center" valign="center" width="90%">
<TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=0><TR><TD><TABLE BGCOLOR="#cccccc" BORDER=0 CELLSPACING=2>
<TR>
<TD ALIGN="right">DED:</TD>
<TD COLSPAN=3 BGCOLOR="#ffffff">
$DED
</TD>
</TR>
<TR>
<TD ALIGN="right">IP</TD>
<TD COLSPAN=5 BGCOLOR="#ffffff">$IP</TD>
</td>
</TR>
</tr>
</table></table>
</body>
</html>
HTML;
You can find more information on Heredoc, and other string information, at the String documentation [php.net] at [php.net...]
Good luck :)
Secondly, you need to break off the echo to use a variable.
//example
<?php
$IP =4;
echo 'The IP is '.$IP.' for your computer';
?>
//output
The IP is 4 for your computer
Some other small mistakes:
<TR>
<TD ALIGN="right">IP</TD>
<TD COLSPAN=5 BGCOLOR="#ffffff"><?echo $IP;?></TD>
</td> <--needs to be removed, you already closed it above
</TR><-needs to be removed, you have one below
</tr>
</table></table>
//needs to be </table></td></tr></table>
and so on.
[edited by: StoutFiles at 2:12 am (utc) on July 3, 2008]