Jump to content

Recommended Posts

[edit] i believe ive posted this in the wrong section D: please could a mod delete or move it! thanks!

 

-----------------------

 

 

Hi

 

Im trying to get :

 - title, newstext, authorId from indexNews

 - id, forename, surname from users

 

where authorId is id 

 

im using pdo, which is where im stuck :P

 

here is what I've done so far :

 

	try {

		$sql = "SELECT i.title, i.newstext, i.authorId, u.id, u.forename, u.surname FROM indexNews as i JOIN users AS u ON (i.authorId = u.id)";
		
		
		//$sql = "SELECT * FROM indexNews";
		foreach ($db->query($sql) as $row) {
			echo '<div class="announceTitle">';
			echo $row['i.title'] .' - '. $row['i.authorId'] . '<br />';
			echo $row['u.surname'].' '.$row['u.forename'].'<br />';
			echo '</div>
				<div class="announceText">';
			echo $row['i.newstext'];
			echo '</div>
				<br />
				<br />';
		}
		
	}
	catch(PDOException $e) {
		echo $e->getMessage();
	}

 

when i run this i get :

 

Notice: Undefined index: i.title in <document path>/index.php on line 100

Notice: Undefined index: i.authorId in <document path>/index.php on line 100

 

 

line 100 is 

 

echo $row['i.title'] .' - '. $row['i.authorId'] . '<br />';
 

 

i think that the issue might be with the array? but i'm not sure.

 

 

I've tried googling and have been looking for a tutorial, but haven't found an answer.

 

could anyone give me some hints as to where i'm going wrong? 

 

Thanks for your time

Edited by goldfishdancer
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.