How to retrive values from dbase

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
umapathy
Forum Newbie
Posts: 14
Joined: Fri Jul 28, 2006 2:21 am
Location: chennai - india

How to retrive values from dbase

Post by umapathy »

Dear all

I have a table. in the table totaly three fields, like name , age , address
i want to display these three fields values in a PHP page. or inside a html table
i need code. i know db connection coding. and i need retrive coding.

Regards
Umapathy
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Are you talking about dbase or database ?
If its the latter, which database are you using - MySQL, PostgreSQL, MS SQL, Sybase, DB2 etc ?
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

Re: How to retrive values from dbase

Post by aerodromoi »

umapathy wrote:Dear all

I have a table. in the table totaly three fields, like name , age , address
i want to display these three fields values in a PHP page. or inside a html table
i need code. i know db connection coding. and i need retrive coding.

Regards
Umapathy
Provided that you're talking about a mysql database:

Code: Select all

<?php
  $host = "";
  $user = "";
  $pass = "";
  $database = "";
  $table = "";  

  $db = @mysql_connect($host, $user, $pass) or die(mysql_error());
  @mysql_select_db($database, $db) or die(mysql_error());
  $query = "SELECT namec,agec,addressc FROM ".$table." ORDER BY namec DESC";
  $result = @mysql_query($query) or die(mysql_error());

  while ($row = mysql_fetch_assoc($result)) {
    print($row['namec'].", ");
    print($row['agec'].", ");
    print($row['addressc']."<br />\n");
  }
  mysql_close($db);
?>
Post Reply