|
-
Jul 18th, 2002, 06:58 PM
#1
Thread Starter
Fanatic Member
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
-
Jul 18th, 2002, 08:01 PM
#2
Fanatic Member
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>");
}
?>
-
Jul 26th, 2002, 09:44 AM
#3
Thread Starter
Fanatic Member
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
-
Jul 26th, 2002, 10:28 AM
#4
Frenzied Member
what is your code, because that should have worked.
-
Jul 26th, 2002, 10:47 AM
#5
Thread Starter
Fanatic Member
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>");
}
?>
-
Jul 26th, 2002, 10:54 AM
#6
Frenzied Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|