Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-22-2005, 06:07 AM   #1 (permalink)
mrfox
Junior Member
 
Join Date: Sep 2005
Posts: 2
Default Getting values from an SQL table on php

How do I use php to select from the DB on to look at a specific item at a column and then display to me another value that is on the same row as the selected value? mysql_query?
mrfox is offline   Reply With Quote
Sponsored Links
Old 09-23-2005, 08:29 PM   #2 (permalink)
kayla
Member
 
Join Date: Jun 2005
Location: Tampa, Fla
Posts: 37
Default

You can just run a query like this for example:
PHP Code:
<?php
// Make a MySQL Connection
mysql_connect("localhost""username""passwd") or die(mysql_error());
mysql_select_db("test_db") or die(mysql_error());

// Get all the data from the "example_table"
$result mysql_query("SELECT * FROM example_table"
or die(
mysql_error()); 

echo 
"<table border='1'>";
echo 
"<tr> <th>Name</th> <th>Age</th> </tr>";
// keeps getting the next row until there are no more to get
while($row mysql_fetch_array$result )) {
// Print out the contents of each row into a table
echo "<tr><td>"
echo 
$row['name'];
echo 
"</td><td>"
echo 
$row['age'];
echo 
"</td></tr>"

echo 
"</table>";

?>

hope this helps
kayla is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 05:20 AM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums