I would like to know how to do a seperate php page where I make AND print a query from my chat database to a php page, so I can show a simple overview of a chat.
EX
Jens: hi this is a great chat
Ally: Yeah great isn't it
In this way I can create a simple message log without going through phpmyadmin
In short....make a query on username and message and then print it in html/php page.
Can anyone help me?
Best regards
Jens Christensen
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2002-07-12
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?PHP
$conn = mysql_connect ("localhost", "root", "")or die ("Konnte keine Verbindung zur Datenbank herstellen");
if ($conn) {echo"Verbindung steht!<br><br>Log.htm liegt im Chat-Verzeichniss!<br><br> ";};
$db_select = mysql_select_db ("chat", $conn);
$query = mysql_query ("SELECT username,message FROM c_messages WHERE username NOT LIKE 'SYS%'");
$anzahl_recs = mysql_num_rows($query);
Hi,
I would like to know how to do a seperate php page where I make AND print a query from my chat database to a php page, so I can show a simple overview of a chat.
EX
Jens: hi this is a great chat
Ally: Yeah great isn't it
In this way I can create a simple message log without going through phpmyadmin
In short....make a query on username and message and then print it in html/php page.
Can anyone help me?
Best regards
Jens Christensen
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Chat-Log</title>
</head>
<body>
<?PHP
$conn = mysql_connect ("localhost", "root", "")or die ("Konnte keine Verbindung zur Datenbank herstellen");
if ($conn) {echo"Verbindung steht!<br><br>Log.htm liegt im Chat-Verzeichniss!<br><br> ";};
$db_select = mysql_select_db ("chat", $conn);
$query = mysql_query ("SELECT username,message FROM c_messages WHERE username NOT LIKE 'SYS%'");
$anzahl_recs = mysql_num_rows($query);
$x = 0;
// Start der tabelle
echo "<table width=100% rules='rows'>";
$text = "<html><title>Chat-LOG</title><body><table width=100% rules='rows'>";
while($row = mysql_fetch_row($query)) {
echo"<tr>";
echo"<td >".$row[0]." :</td>";
echo"<td>".$row[1]."</td>";
echo"</tr>";
$text = $text."<tr><td>".$row[0]."</td><td>".$row[1]."</td></tr>" ;
}//end while
echo "</table>";
$text = $text."</table></body></html>" ;
$fp = fopen ("log.htm","w");
fwrite($fp,$text);
fclose($fp);
mysql_close($conn);
?>
</body>
</html>