dzhax Posted March 10, 2011 Share Posted March 10, 2011 So I am making a chat program for a friend and when i run a query to load all existing chat into the div i am only getting the most recent result and not all results in the databaseCode: $query = 'SELECT * FROM chatLog'; $result = mysql_query($query,$chatWindow) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<span class='alias' style='color:red; font-weight:bold; font-size:13px;>".$row['user'].": </span>".$row['message']."<br>"; } if i run mysql_num_rows($result) it returns 4 so 4 results should print out correct? Link to comment Share on other sites More sharing options...
thescientist Posted March 10, 2011 Share Posted March 10, 2011 So I am making a chat program for a friend and when i run a query to load all existing chat into the div i am only getting the most recent result and not all results in the databaseCode: $query = 'SELECT * FROM chatLog'; $result = mysql_query($query,$chatWindow) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo "<span class='alias' style='color:red; font-weight:bold; font-size:13px;>".$row['user'].": </span>".$row['message']."<br>"; } if i run mysql_num_rows($result) it returns 4 so 4 results should print out correct? you have an error in your HTML outputstyle='color:red; font-weight:bold; font-size:13px;>" you are missing the closing ' for the style attribute. may or may not be relevant. Link to comment Share on other sites More sharing options...
dzhax Posted March 10, 2011 Author Share Posted March 10, 2011 wow its amazing what a single quote can do ... lol thanks you rock! Link to comment Share on other sites More sharing options...
shadowayex Posted March 11, 2011 Share Posted March 11, 2011 wow its amazing what a single quote can do ... lol thanks you rock!I would also urge you to give your span a class and do your CSS either in the head section of the page, or in an external sheet and link it in. Inline styles are technically correct, but look messy. CSS was meant to clean up mark-up. Link to comment Share on other sites More sharing options...
thescientist Posted March 11, 2011 Share Posted March 11, 2011 wow its amazing what a single quote can do ... lol thanks you rock!view source ftw Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.