Current location: Hot Scripts Forums » Programming Languages » PHP » retrieve data from database


retrieve data from database

Reply
  #1 (permalink)  
Old 07-28-03, 09:13 AM
vioss vioss is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
retrieve data from database

how to retrieve information from the database to the PHP webpage????

below is a table in MYSQL
-------------------------------------------------------------
Name l Year started l address l id l
-------------------------------------------------------------
john l 2000 l London l J007 l
-------------------------------------------------------------

how can i just select the year started (2000) to show at the PHP web page?
Reply With Quote
  #2 (permalink)  
Old 07-28-03, 11:52 AM
BradC BradC is offline
Newbie Coder
 
Join Date: Jul 2003
Location: Indianapolis, IN
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Very basic... but will pull the info..

Code:
<?php
define("SQL_SERVER", "localhost");
define("SQL_UID", "username");
define("SQL_PWD", "password");
define("SQL_DB", "database");

$connection = mysql_pconnect(SQL_SERVER, SQL_UID, SQL_PWD);
mysql_select_db(SQL_DB, $connection);

$idname = "J007"; // if you have more documents you can select a different user.

$sql = "SELECT * FROM <tablename> WHERE id = '$idname'";
$result = mysql_query($sql);

$Name = mysql_result($result,0,"Name");
$Year = mysql_result($result,0,"Year started");
$Address = mysql_result($result,0,"address");
$ID = mysql_result($result,0,"id");

echo" Name = $Name<br>Year = $Year<br>Address = $Address<br>ID = $ID";

?>
Reply With Quote
  #3 (permalink)  
Old 07-30-03, 12:48 PM
tai fu's Avatar
tai fu tai fu is offline
me
 
Join Date: Jul 2003
Location: Greece
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Here our friend BradC has suplied you with the basic PHP functions for accessing a MySql database, all you have to do now is learn the Mysql - PHP queries at www.w3schools.com (free )..
__________________
let my source be on your side...
<a href="http://www.programersguild.com">Programer's Guild</a><a href="http://gcf.linuxserver.at">Gnome Code factory
</a>
Reply With Quote
  #4 (permalink)  
Old 07-31-03, 12:09 PM
vioss vioss is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
thanks here first,

then is it possible to store and then retrive back the data that i just store into the database by using PHP code?
Reply With Quote
  #5 (permalink)  
Old 08-03-03, 04:51 AM
jv2222 jv2222 is offline
The Freshmaker
 
Join Date: Jun 2003
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
__________________
Author of <a href=http://www.hotscripts.com/Detailed/18290.html target=_blank>ezSQL</a> (makes life soooo easy when working with databases)
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SysDB : how to synchronise XML data with database... Simonoff General Advertisements 0 09-12-03 05:15 AM
retrieve data from combo box sasi ASP 1 09-03-03 06:16 PM
QueryString and retrieve data from database pjm ASP 3 08-11-03 02:21 PM
Share database over the internet nitinkedia PHP 0 07-11-03 12:22 AM
Share database over the Internet nitinkedia New Members & Introductions 1 07-10-03 02:50 PM


All times are GMT -5. The time now is 04:12 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.