<?php // Create a connection to your database. // Query database and select the last 10 entries. $data = mysql_query("SELECT * FROM video ORDER BY id DESC LIMIT 50"); while($row = mysql_fetch_array($data)) { echo " ".$row[title]." "; } ?> Code (markup): If I try to put, say, <div class="cool"> ".$row[title]." </div> It displays an error in the query although that div class works fine within barebone php. Any thoughts why this doesn't work in the queries?
Note the single and double quote after the word cool. Try echo "<li class='cool'". $row[title]. "</li>";
Huh, that's odd. Whenever I use that tag it kinda messes up my "cool" div. It adds a *-symbol to every div. Odd, huh?
That one doesn't seem to do it either. I have a lot of "-quotes in my query code, maybe that's why print messes it up?
Try putting the single quotes around title that I missed. It may be echoing your sql statement if it isn't properly formated.
Better one would be print '<div class="cool">'.$row['title'].'</div>'; PHP: --- Regarding the * symbol 1. Use your php editor to search for this * in your file? 2. If it wasn't found in your file, it must be from your database - ads2help
And even better would be echo '<div class="cool">'; echo $row['title']; echo '</div>'; PHP: What I want to say is - you can always improve your code
mhm... why not just escape out of php? ?> <div class="cool"> <?= $row['title']; ?> </div> works like a charm
Well u can try this <?php // Create a connection to your database. // Query database and select the last 10 entries. $data = mysql_query("SELECT * FROM video ORDER BY id DESC LIMIT 50"); while($row = mysql_fetch_array($data)) { echo "<div class='cool'>".$row['title']."</div>"; } ?> Code (markup): This willl work Regards, Stylesofts Developing Team