luke101 Posted September 6, 2007 Share Posted September 6, 2007 Hello, I am having a problem fetching the data from the database. When i use $row[0]; $row[1]; The code below does not works. How would I make the code below work? $resourcearray = "SELECT mainlist.title, resourcelist.title, resourcelist.description, resourcelist.Resource_Date FROM mainlist inner join resourcelist on mainlist.id = resourcelist.MainList_Key WHERE resourcelist.author=$userid"; $result = selectstatement($resourcearray); echo "Resources: <br />"; while($row = mysql_fetch_array($result)) { ?> <strong><?php echo $row['mainlist.title']; ?></strong><br /> <?php echo $row['resourcelist.title']; ?><br /> <?php echo $row['resourcelist.description']; ?><br /> <br /><br /> <?php } Quote Link to comment https://forums.phpfreaks.com/topic/68253-problem-fetching-database-results/ Share on other sites More sharing options...
GingerRobot Posted September 6, 2007 Share Posted September 6, 2007 Im sorry, you're really going to have to help us help you here. The code below works. How would I make the code below work? Im guessing that was a typo, and 'the code below' doesn't work. However, what do you mean by doesn't work? What happens? What's supposed to happen? Do you get an error? What 'problem' are you having? Im not being rude, its just impossible to help without knowing what we're trying to help with! Quote Link to comment https://forums.phpfreaks.com/topic/68253-problem-fetching-database-results/#findComment-343122 Share on other sites More sharing options...
luke101 Posted September 6, 2007 Author Share Posted September 6, 2007 when i use: $row[0]; $row[1]; Then the code works When I use : $row['mainlist.title']; $row['resourcelist.title']; $row['resourcelist.description']; Then the code does not work I would like to use the $row['mainlist.title']; sytax to get information from the database. Can i do this? Quote Link to comment https://forums.phpfreaks.com/topic/68253-problem-fetching-database-results/#findComment-343124 Share on other sites More sharing options...
GingerRobot Posted September 6, 2007 Share Posted September 6, 2007 Ah ok, well you dont need the table name in the key of the array. Since you have more than one field with the same name(which are across differant tables) you'll need to use AS to rename the results. For example: $resourcearray = "SELECT mainlist.title AS maintitle..." You'd then use that by using $row['maintitle']; Quote Link to comment https://forums.phpfreaks.com/topic/68253-problem-fetching-database-results/#findComment-343143 Share on other sites More sharing options...
luke101 Posted September 6, 2007 Author Share Posted September 6, 2007 Oh my goodness, that worked Thank you very much. I appreciate it Quote Link to comment https://forums.phpfreaks.com/topic/68253-problem-fetching-database-results/#findComment-343156 Share on other sites More sharing options...
GingerRobot Posted September 6, 2007 Share Posted September 6, 2007 No need to sound so suprised Glad it worked. Quote Link to comment https://forums.phpfreaks.com/topic/68253-problem-fetching-database-results/#findComment-343165 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.