GetDotted Domains

Viewing Thread:
"MySQL - Displaying data in a table..."

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Fri 22/08/03 at 16:57
Regular
Posts: 787
There you go Mod.

Just as you asked!

Anyway.

Does anyone know about MySQL and displaying the data in a table?

I've got a basic script to display it like this (http://www.phi11ip.com/mysql/display.php) but I want to be able to display it out of the rows and something like it shows at the bottom of the page...

Does anybody know how to do anything like this? If you can give me the general idea of what to do with a small example or a link to one I should be able to modify it and get it working...

Thanks.
Fri 22/08/03 at 16:57
Regular
"Chavez, just hush.."
Posts: 11,080
There you go Mod.

Just as you asked!

Anyway.

Does anyone know about MySQL and displaying the data in a table?

I've got a basic script to display it like this (http://www.phi11ip.com/mysql/display.php) but I want to be able to display it out of the rows and something like it shows at the bottom of the page...

Does anybody know how to do anything like this? If you can give me the general idea of what to do with a small example or a link to one I should be able to modify it and get it working...

Thanks.
Fri 22/08/03 at 17:18
Regular
"It goes so quickly"
Posts: 4,083
So, you mean in a different order than it is in the Database?
Fri 22/08/03 at 17:27
Regular
"Chavez, just hush.."
Posts: 11,080
I can change the database order no problem.

I just don't know how to tell certain fields where to be put...

I've only got a script that prints the whole line...
Fri 22/08/03 at 17:29
Regular
"It goes so quickly"
Posts: 4,083
Can you put that code here, as I know what you want, but it isn't as fresh in my head as I'd like it to be.
Fri 22/08/03 at 17:31
Regular
"It goes so quickly"
Posts: 4,083
You can use the mysql_fetch_array to get the results in an array with the field names attached.

Example:
# DATABASE CONNECTION CODE HERE, which you should already have.

$results = mysql_query(SELECT * FROM TableName);

# Loop through each row of data.
while ($a_row = mysql_fetch_array($results)) {

}
?>
Fri 22/08/03 at 17:33
Regular
"It goes so quickly"
Posts: 4,083
Sorry.

You can use the mysql_fetch_array to get the results in an array with the field names attached.

Example:
# DATABASE CONNECTION CODE HERE, which you should already have.

$results = mysql_query(SELECT * FROM TableName);

# Loop through each row of data.
while ($a_row = mysql_fetch_array($results)) {
print "$a_row[One_Field_name]\n";
print "$a_row[Another_Field_name]\n";
print "$a_row[One_More_Field_name]\n";
}
?>
Fri 22/08/03 at 17:38
Regular
"Chavez, just hush.."
Posts: 11,080
$result = mysql_query( "SELECT * FROM text ORDER BY id DESC LIMIT 3;" )

or die("SELECT Error: ".mysql_error());

$num_rows = mysql_num_rows($result);

print "There are $num_rows records.

";

print "

\n";

while ($get_info = mysql_fetch_row($result)){

print "\n";

foreach ($get_info as $field)

print "\t\n";

print "\n";

}

print "
$field
\n";

mysql_close($db);



?>


At the moment it's this. (minus the top)

I want to change the way it displays the data, change the layout of the table...
Fri 22/08/03 at 17:41
Regular
"Chavez, just hush.."
Posts: 11,080
I can see faintly what I have to do now...

I'll have a go and see...
Fri 22/08/03 at 17:46
Regular
"Chavez, just hush.."
Posts: 11,080
Ahhhhhhhhhhhhh.

I might be able to get somewhere now!
Fri 22/08/03 at 17:48
Regular
"It goes so quickly"
Posts: 4,083
mysql_fetch_array makes placment of the data a lot easier.

Good luck.

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Top-notch internet service
Excellent internet service and customer service. Top-notch in replying to my comments.
Duncan
Best Provider
The best provider I know of, never a problem, recommend highly
Paul

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.