Computer Forum  

Go Back   Computer Forum > Computer Forums > Programming Forum > PHP Forum

PHP Forum PHP Forum. PHP Programming questions and answers here.


newbie: accessing columns in a select

PHP Forum

PHP Forum. PHP Programming questions and answers here.


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-23-2005, 11:18 PM
Jeff
Guest
 
Posts: n/a
Jeff RSS Feed
newbie: accessing columns in a select

php version 5

Here is some code from index.php:
$sql = "select A.text, A.link, B.text, B.link, C.text, C.link from menu A,
menu B left outer join menu C on B.MenuItemID = C.parent where B.parent =
A.MenuItemID and A.MenuItemID = $MenuItem";

$result = $dbh->query($sql);
while ($menuitem = $result->fetch_assoc())
{
echo "<a href={$menuitem['Link']}>{$menuitem['text']}</a>";
echo "<br>";
}

As you can see from my select, I've joined the menu table with itself 3
times...My problem is in this line:
echo "<a href={$menuitem['A.Link']}>{$menuitem['A.text']}</a>";

I cannot access the columns in the resulset using A.Link, A.text, B.Link
etc... But I want to access them, how do I access the columns here?

Please, help me with this problem!


Jeff


Reply With Quote
  #2 (permalink)  
Old 11-23-2005, 11:45 PM
Carl
Guest
 
Posts: n/a
Carl RSS Feed
newbie: accessing columns in a select

Jeff wrote:

Try :

$sql = "select A.text as atext, A.link as alink, B.text as btext, B.link
as blink, C.text as ctext,"..., etc.

Then reference them by their assigned name (i.e alink/atext).

Carl.
Reply With Quote
  #3 (permalink)  
Old 11-24-2005, 12:00 AM
Jeff
Guest
 
Posts: n/a
Jeff RSS Feed
newbie: accessing columns in a select

thanks, it works now

"Carl" <_Nospam_@_DO_NOT_.USE> wrote in message
news:138hf.23882$dO2.10617@newssvr29.news.prodigy. net...


Reply With Quote
Reply


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need ajax script, when i select country from select box than its cities should... zahidsardar99 AJAX Forum 0 08-30-2008 12:38 AM
In MYSQL, Can I have the sum of two columns in 1 query? pot Mysql Forum 0 06-05-2008 01:51 PM
In MySQL, does having too many columns make a difference when those columns are not Anonymous Mysql Forum 0 01-11-2008 02:34 AM
Reordering Columns Bruno Mysql Forum 0 05-22-2005 01:49 PM
Newbie q: Make user select "yes" to advance to specified URL tHatDudeUK PHP Forum 1 11-15-2004 09:07 AM


All times are GMT. The time now is 11:48 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93