Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2006-03-18, 09:19 AM
Junior Member
 
Join Date: Mar 2006
Posts: 2
Theavenger
Default

Hy there peeps,

ive been working with php/Sql now for my website and i keep getting more skilled at it. Half my site / script run on database retrieval & storage and for that i have been using the mysql_fetch_object retrieval method. Scripting like this.


Code:
mysql_connect("hostname","username","password");
mysql_select_db("databasename");
$query="select x from tablename";
$sql=mysql_query($query) or die (mysql_error());
while ($obj=mysql_fetch_object($sql)) {
$variable1=$obj->databasefield; ÂÂ*
...
}
where x is needed data fields

The problmel is, i think this isnt one of the easiest methods of retrieving data from a database to work with. Nor is this method easy to remember. So my question is, is there a more easier way to retrieve data in a database to work with.

Any help appreciated
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 2006-03-18, 09:23 AM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

fetch_row is about the same.


$result = mysql_query("select x from table");
while(list($listFields) = mysql_fetch_row($result)){

}
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
  #3 (permalink)  
Old 2006-03-18, 09:33 AM
Junior Member
 
Join Date: Mar 2006
Posts: 2
Theavenger
Default

thx but thats not totally what im looking for, in some of my scripts i only need 1 or 2 fields from a certain table / database. so when i need multiple fields out of multiple different databases this isnt one of the easiest scripts to work with.

My question exactly is, is there an easier way to the whole $sql ....
while .... stuff. I'm lookin for a complete easier method / and easier to remember. Currently the only way i succeed at this is to open a page where it is already active, and copy/modify where needed.
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

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



All times are GMT -5. The time now is 11:07 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.