Jump to content


Photo

How to Display MySQL Data?? [SOLVED]


  • Please log in to reply
4 replies to this topic

#1 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 01 August 2006 - 10:17 AM

I was wondering how you would display MySQL data, I want to have an information page that displays username, e-mail, etc. I have all that in a db, called "zyco_zycologin" and table called "users"
Link shortener with advanced, detailed statistics:

http://tyny.us/

#2 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 01 August 2006 - 10:20 AM

Check out this mysql tutorial from PHP freaks.  If you still have trouble, come back and ask questions

PHP freaks mysql tutorial
If you're not part of the solution, you're part of the precipitate

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 01 August 2006 - 10:30 AM

This shoud display all contents from the users table:
<?php

// connect to database here
$conn = mysql_connectr('localhost' 'username', 'password') or die('Unable to connect to MySQL ' . mysql_error());

// select our database
mysql_select_db('zyco_zycologin', $conn);

// setup our query:
$sql = 'SELECT * FROM users ORDER BY username ASC';

// perform our query:
$result = mysql_query($sq, $conn) or die("Unable to perform query $sql<br />" . mysql_error());

// start our table
echo '<table border="0" cellpadding="0" cellspacing="0" width="90%" align="center">
';

// show contents of database:
while($row = mysql_fetch_assoc($result))
{
    // echo each field in the database
    echo '<tr><td>' . implode('</td><td>', $row) . "</td></tr>\n";
}

// close our table:
echo '</table>';

?>

Have a read of the comments if you are unsure.

#4 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 01 August 2006 - 10:35 AM

This is the best example for getting informations from mysql.
http://www.phpfreaks...ic,31047.0.html

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#5 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 01 August 2006 - 10:46 AM

Thanks everyone!! I got it!!
Link shortener with advanced, detailed statistics:

http://tyny.us/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users