Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Help] Retrieve data from database and display on page

Junior Spellweaver
Joined
Mar 22, 2008
Messages
145
Reaction score
13
I feel like a newbie right now :p. Right now i have a user system set up on my site. I want it were when people log in, they get brung to a page with all there stats like About me, facbook link, URL, Ect. But i have a problem. Im having trouble extracting the database items from the phpmyadmin. Ill "Like" who ever helps :)

Edit: Could someone provide me with a code that shows the proper way to extract the data?
 
Last edited:
Newbie Spellweaver
Joined
Dec 16, 2010
Messages
20
Reaction score
2
Using PHP you can run a MySQL SELECT query to fetch the data out of the database. You have several options in fetching information from MySQL. PHP provide several functions for this. The first one is mysql_fetch_array()which fetch a result row as an associative array, a numeric array, or both.

Example

<?php
include 'config.php';
include 'opendb.php';

$query = "SELECT name, subject, message FROM contact";
$result = mysql_query($query);

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "Name :{$row['name']} <br>" .
"Subject : {$row['subject']} <br>" .
"Message : {$row['message']} <br><br>";
}

include 'closedb.php';
?>

The while() loop will keep fetching new rows until mysql_fetch_array() returns FALSE, which means there are no more rows to fetch. The content of the rows are assigned to the variable $row and the values in row are then printed. Always remember to put curly brackets when you want to insert an array value directly into a string.

- ITSpecial
 
Junior Spellweaver
Joined
Mar 22, 2008
Messages
145
Reaction score
13
Thanks for the quick reply,
 
Last edited:
Back
Top