Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 19th, 2003, 05:47 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Moharo
Default retrieving single value from database

hello there

my question is what is the best way to get a singe value (field) from the database. i would like to know what is the most efficient and fastest way to get it. i was thinking about mysql_result() but is there anything else that might be helpful? is there anyway i can store values for usage in other pages? thanks :):):)



the genuine genius
__________________
www.campusgrind.com - college portal
 
Old July 21st, 2003, 02:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

mysql_result is the way to go if you only need ONE field. Of course, if you only need the one field, be sure to write your query such that it only selects the field you need! Don't select more rows or columns than you plan on using.


Take care,

Nik
http://www.bigaction.org/
 
Old July 5th, 2005, 03:29 AM
Registered User
 
Join Date: Jul 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to rhythm
Default

well code below should be better for u :

<?
$server = "localhost";
$db = "database_name";
$sqlQuery = "Select * from tablename"
$link = $mysql_connect($server);

$mysql_select_db($db,$link);
$result = mysql_query($sqlQuery,$link);

for($row=mysql_fetch_array($result)){

echo stripslashes[$row("field_name")]
}
?>

happy coding






Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieving from database... URGENT!!! roryosullivan JSP Basics 1 March 9th, 2005 03:11 PM
NEED HELP! retrieving from database nvillare .NET Web Services 5 October 22nd, 2004 12:37 AM
problem retrieving from database rajuru Beginning PHP 2 October 8th, 2004 12:34 PM
NEED HELP! retrieving from database nvillare ADO.NET 1 December 2nd, 2003 10:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.