Jump to content

Recommended Posts

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
}

Link to comment
https://forums.phpfreaks.com/topic/68253-problem-fetching-database-results/
Share on other sites

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!

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?

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'];

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.