Web Design and Development Forums

[SOLVED] Use info from Database in a script ???

This is a discussion on "[SOLVED] Use info from Database in a script ???" within the PHP Forum section. This forum, and the thread "[SOLVED] Use info from Database in a script ??? are both part of the Program Your Website category.


Go Back   Webforumz.com > Program Your Website > PHP Forum

Welcome to Webforumz.com.
Register Now Register now!

Reply
 
LinkBack Thread Tools Rate Thread
Old May 1st, 2008, 01:50   #1 (permalink)
Junior Member
 
Join Date: Sep 2006
Location: Here
Posts: 31
[SOLVED] Use info from Database in a script ???

I can query a database and display results successfully.

Does anyone know how I can find a record according to an ID number, within the record, and put the result (email) into a variable for further use in the script?

Thanks
__________________
If computers ruled the world.... Oh, wait. Never mind.
WebNinja is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 1st, 2008, 04:54   #2 (permalink)
Junior Member
 
Join Date: Apr 2007
Location: Kansas
Age: 18
Posts: 33
Send a message via AIM to BRONIC
Re: Use info from Database in a script ???

could u please post your code?

but it sounds to me like u ar just doing something like:

PHP: Select all

$query "SELECT email FROM sometable WHERE id = '$yourid' ";

$result mysql_query($query) or die("Couldn't execute query");
$rowmysql_fetch_array($result);
$email $row["email"]; 
and that should store your email that is paired with that user id into the variable $email.


not sure if this is what u r looking for
BRONIC is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old May 3rd, 2008, 00:59   #3 (permalink)
Junior Member
 
Join Date: Sep 2006
Location: Here
Posts: 31
Re: Use info from Database in a script ???

Thanks for your suggestion. I'm going to give that a try. I'm new to PHP so I'm still trying to figure out how things should be set up. Here my code so far. It just queries and displays two selected fields from all records in the database.

Code: Select all
<?php
$db="DATABASE";
$link = mysql_connect("localhost","USERNAME","PASSWORD");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
$result = mysql_query( "SELECT Order_Number,Bill_Email_Address FROM Orders" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=200 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
mysql_close($link);
?>
Here is what I have now.

Code: Select all
<?php
$db="DATABASE";
$link = mysql_connect("localhost","USERNAME","PASSWORD");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());


$query = "SELECT Bill_Email_Address FROM Orders WHERE Order_Number='$order_id'";
$result = mysql_query($query) or die("Couldn't execute query");
$row= mysql_fetch_array($result);
$email = $row["Bill_Email_Address"];

print "Working with Order Number: ";
echo "$order_id<br />";
print "Sending update to ";
echo "$email<br />";
mysql_close($link);
?>
Worked great! Thanks Bronic.
__________________
If computers ruled the world.... Oh, wait. Never mind.

Last edited by WebNinja; May 3rd, 2008 at 17:12.
WebNinja is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] PHP database code issue acrikey PHP Forum 82 Mar 28th, 2008 15:05
[SOLVED] Need Helping Linking Database bjbaughcum03 ASP Forum 16 Nov 1st, 2007 07:23
[SOLVED] Who does my PHP script run as? Kropotkin PHP Forum 3 Oct 12th, 2007 12:07
Database Update script problems as22607 PHP Forum 10 May 14th, 2007 18:08
Looking for Script to sort table data (& populate database) toasty PHP Forum 1 Oct 13th, 2006 17:42



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 18:59.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59