UK WEB HOSTING FORUM FOR DISCUSSION ON WEB HOSTING SERVICE AND SUPPORT
LINUX HOSTING WINDOWS HOSTING PACKAGES SHOPPING CART OSCOMMERCE ZEN CART AGORA
ECOMMERCE HOSTING ASP MSSQL FRONTPAGE HOSTING PHP MYSQL HOSTING DISCUSSION FORUM
CPANEL RESELLER HOSTING DEDICATED SERVER VPS HOSTING PLESK VIRTUOZZO
Quick Search
Your forum announcement here!

  UK Web Hosting | Dedicated Server Windows and Linux VPS Forum > Technical Support > Tutorials / How to?

Reply
 
LinkBack (1) Thread Tools Search this Thread Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 06-06-2008, 15:27
Ben Ben is offline
Premium Member
 
Join Date: Jan 2007
Location: setcookie()
Posts: 899
Send a message via AIM to Ben Send a message via MSN to Ben Send a message via Yahoo to Ben
Default Using mysql_fetch_object() function in PHP

So what does mysql_fetch_object() do? It fetches a result row (or field) as an object. Now imagine you had a MySQL table named users and a field/row named username. If you wanted to display these usernames in descending order, you'd first of all create a MySQL query:

PHP Code:
<?php
$sql
=mysql_query("SELECT * FROM `users`");
while(
$object=mysql_fetch_object($sql)) {
echo 
$object->username."<br />";
}
?>
Okay, so basically mysql_query() is to create a new MySQL query to interact with the database. If you know a little SQL, SELECT * means select ALL (* = wildcard) FROM `users` table.

The while() loop - well, take a wild guess. "Loops" are continual chains of events that never really stop. Or, until the end of time. But in this case it'll loop all of the values in that specific field until the end of all values in that field .

$object will be the object variable of that MySQL query - so therefore, $object->username would select the username field in that users table. You can't select anything outside of the users table unless you specify that in a seperate MySQL query. You can learn more about SQL Server and find tutorials here.

So there you are . Remember you can get more less detailed information about a function at the PHP website hosting by going to php.net/function_name (replacing function_name with, for example, mysql_fetch_object).

Good luck!

References you may find useful:

PHP: mysql_real_escape_string - Manual
PHP: mysql_fetch_array - Manual
PHP: mysql_fetch_assoc - Manual
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.



To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
-
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
-
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.



To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.



To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.



To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by Ben; 06-06-2008 at 15:29.
Reply With Quote
  #2 (permalink)  
Old 05-08-2008, 12:00
Banned
 
Join Date: Aug 2008
Posts: 7
Default

mysql_fetch_object() is similar to mysql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).

Last edited by Ben; 06-08-2008 at 07:36. Reason: spammed advertisements
Reply With Quote
Reply

LinkBacks (?)
LinkBack to this Thread: http://www.eukhost.com/forums/f15/using-mysql_fetch_object-function-php-5074/
Posted By For Type Date
UK Web Hosting | Dedicated Server Windows and Linux VPS Forum This thread Refback 12-06-2008 13:31


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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. The time now is 16:29.

 

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by Web Hosting 3.1.0
Copyright © 2001-2008, eUKhost.com. All rights reserved.

 
Site Map

VPS Hosting
VPS Hosting plans

Dedicated Server Hosting
Dedicated Server plans

Business Web Hosting
100% uptime Hosting

Cpanel Hosting
cPanel Shared Hosting

Reseller Hosting
Reseller Web Hosting

Windows Hosting
Windows Shared Hosting

Windows VPS

Windows VPS Hosting

Semi Dedicated Servers
Semi-Dedicated Hosting

Dedicated Server Mirroring
Dedicated Server Mirroring

Webhosting Knowledgebase
Frequently asked Questions

Web Hosting Blog
eUKhost Blog

Web Hosting Support
Support Helpdesk

UK Data Center
eUKhost Datacenter

Web Hosting Forum
eUKhost Forum

Support Tutorials
Online Flash Tutorials

Offsite Back-up Plans
Remote Backup Service

Customer Testimonials
eUK Customer Testimonials


knowledgebase articles

eUKhost.com Services

Pre-Sales Questions
Pre-sales FAQ's

Domain Names
Domain registration FAQ's

cPanel Hosting
cPanel Hosting FAQ's

Windows Web Hosting
Plesk Control Panel

Reseller Hosting
Reseller Hosting FAQ's

VPS Hosting
Virtual Private Server

Semi-Dedicated Servers
Semi-Dedicated FAQ's

Dedicated Servers
Dedicated Server Hosting


popular blog categories


Web Hosting
Website Hosting articles

UK Web Hosting
UK Hosting articles

Dedicated Server Hosting
Dedicated Server guidelines

VPS Hosting
VPS hosting articles

cPanel Hosting
cPanel Hosting articles

Linux Operating System
Linux Operating techniques

Windows Web Hosting
Windows plesk articles