while ($php_row = mysql_fetch_object($php_resultID)) Help

Posted on 2006-06-04
Last Modified: 2013-12-12
I have the following SQL statement which runs fine as a raw SQL query.  But when I put it into my PHP script I can't seem to access the u_owned_by.full_name element.

Here is my SQL statement:

select t.created_on_date, t.check_status_on_date, t.due_on_date,, t.title, u_owned_by.full_name, u_assigned_to.full_name, c_category.category, s_subcategory.subcategory, t.description, t.comments
from ralph_Tasks t, ralph_Cat c, ralph_Sub s
left join ralph_Users u_owned_by on = t.owned_by
left join ralph_Users u_assigned_to on = t.assigned_to
left join ralph_Cat c_category on = t.category
left join ralph_Sub s_subcategory on = t.subcategory;

Here is my PHP part:
while ($php_row = mysql_fetch_object($php_resultID))
        <?php echo $php_row->u_owned_by.full_name?>

All I see on the web page is 'full_name' instead of the actual name I see when I run the SQL query.  So, I guess I don't have the php access part right.
Question by:rfresh
    LVL 2

    Expert Comment

    try this..

    while ($php_row == mysql_fetch_object($php_resultID)){
            echo $php_row=>u_owned_by.full_name;
    LVL 16

    Expert Comment

    while ($php_row = mysql_fetch_object($php_resultID))
            <?php= $php_row->full_name?>
    don't refere to table's name, just column's name

    Author Comment

    >don't refere to table's name, just column's name

    The full_name field is in the Users Table.  Tasks fields Category and SubCategory are INT indexes pointing to full_name in Users.  Thus

    u_owned_by.full_name, u_assigned_to.full_name

    In Tasks Table, one record shows owned_by a value 5 which in Users matches the ID value of 5 for full_name == Ralph.  In Tasks, assigned_to shows value of 8 which in Users table show index of 8 has full_name == Steve.  So, I need to distungish specifically for each one.  That's way I had

     <?php echo $php_row->u_owned_by.full_name?>

    but it wasn't working.  BTW when I  used full_name only it worked for owned_by but not assigned_to - when I used full_name only, both showed the same text value (Ralph).

    LVL 8

    Accepted Solution

    why dun u use "as"
    i meant  u_owned_by.full_name as owned_full_name, u_assigned_to.full_name as assigned_full_name

    and then
    echo $php_row->owned_full_name

    LVL 16

    Expert Comment

    PHP is not mySQL, within PHP, you CAN'T refere to table's name, you must give your field a unique name using "as"

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Easy Project Management (No User Manual Required)

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now