Hi all. I have the following php script that supposed to output mysql data in specified html format. The data is chat trascript but unfortuently it never outputs data and it gives me no error. could any one look at this and let me know what i am doing wrong.Thanks
The script supposed to create one line of html as shown for each row in db.
and if the row belongs to visitor it change the color of the text to #800080( if column textdataby has value you then we know it is for visitor text)
displaydata.php
The script supposed to create one line of html as shown for each row in db.
Code:
<font COLOR='#0000FF'>Edward: </font><font COLOR='#000000'>How are you?</font><br>
Code:
<font COLOR='#0000FF'>Visitor: </font><font COLOR='#800080'>I am doing good</font><br>
displaydata.php
Code:
<?
Header('Cache-Control: no-cache');
Header('Pragma: no-cache');
$sessionkey=$_GET['sessionkey'];
$server = "localhost"; // MySQL hostname
$username = "root"; // MySQL username
$password = "root"; // MySQL password
$dbname = "data"; // MySQL db name
$db = mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($dbname) or die(mysql_error());
//my otherquery
$res = mysql_query("SELECT textdata,textdataby,type,d FROM chattextuser where sessionkey='$sessionkey' ORDER BY date ASC") or die('<error>'.mysql_error().'</error>');
?>
<html>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<body scroll='no' leftmargin='0' topmargin='0' oncontextmenu='return true'>
<iframe name="textFrame" frameborder="0" border="0" width=100% height=100% ></iframe>
<script language="javascript">
function create()
{
var win = window.textFrame;
var doc = win.document;
doc.open("text/html");
doc.write("<html>\r\n<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\r\n<body \r\nborder='0' topmargin='0' bottommargin='0' leftmargin='10' rightmargin='10'>\r\n<center>\r\n<TABLE border='0' cellspacing='0' cellpadding='0' width='100%'>\r\n<TR><TD DIR='LTR'>\r\n<FONT FACE='Arial' SIZE='2'>\r\n<?
while($row = mysql_fetch_assoc($res))
{
echo '<font COLOR='#0000FF'>'.$row['textdata'].': </font><font COLOR='#000000'>'.$row['textdataby'].'</font><br>';
}
?>
</FONT>\r\n</TD></TR></TABLE></center>\r\n</BODY>\r\n</HTML>\r\n");
doc.close();
}
function scroll()
{
var win = window.textFrame;
win.scroll(0, 50000);
}
create();
scroll();
</script>
</body>
</html>