-
listing all records?
How can i loop through all the records in a table called movie and print the info in a table for just the field Title?
Example:
Rows look like this in the database
row1: Title Review Image Comments
so i want to print out the Title field for all the rows in a table 1 in each cell. Also is there a way to say put 20 on each page?
thanks for da help :D
-
PHP Code:
<?php
$db = mysql_connect("localhost", "root");
mysql_select_db("yourdb",$db);
$result = mysql_query("SELECT * FROM yourtable",$db);
while ($myrow = mysql_fetch_array($result)) {
$title=$myrow["title"];
//add some html to make it table like
print("$title<br>");
}
?>
-
doesn't seem to list anything when I try it. And yes I did change the info to work with my db, but i get a blank page :(
-
what is your code, because that should have worked.
-
PHP Code:
<?php
$db = mysql_connect("localhost", "stickman373", "******");
mysql_select_db("stickman373_uk_db",$db);
$result = mysql_query("SELECT Title FROM movie",$db);
while ($myrow = mysql_fetch_array($result)) {
$title=$myrow['Title'];
//add some html to make it table like
print("$title<br>");
}
?>
The Above code works, but the below code does not. Why all I change is what is selects from the movie table?
PHP Code:
<?php
$db = mysql_connect("localhost", "stickman373", "******");
mysql_select_db("stickman373_uk_db",$db);
$result = mysql_query("SELECT * FROM movie",$db);
while ($myrow = mysql_fetch_array($result)) {
$title=$myrow['Title'];
//add some html to make it table like
print("$title<br>");
}
?>
-
there is nothing wrong with any of that code. it should run on both of them.
did you restart your computer to see if the cache isn't making it bug up? I see nothing wrong with the code.