Intranet Journal

Go Back   IT Management Forum > Intranet Journal

Intranet Journal The new discussion forum for Intranet Journal readers. Leave comments and questions for IJ authors. Suggest story ideas and provide feedback.

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-19-2008, 12:09 PM
joelvardy joelvardy is offline
Registered User
 
Join Date: Jan 2008
Posts: 4
Multiple sql querys in one php page

I have a php cms and I would like to retrieve the data for the article into the page (works fine) inside that article is a php echo to bring something from the users table.

How would I go about making this work

Thanks, Joel
Reply With Quote
  #2 (permalink)  
Old 06-14-2008, 08:39 AM
marzar00 marzar00 is offline
Registered User
 
Join Date: Jun 2008
Posts: 22
G'day joelvardy,

I two am trying to get this works. Firstly I have changed the 'cmsarticles' to 'news'. I have also added a field in the 'news' table called author which holds the authors/users unique ID. What I am trying to do, which I believe is what you are also trying to do is to output a list of news articles and their individual authors. The code I am playing with at the moment is:
PHP Code:
<?php
// Require the database class
require_once('includes/DbConnector.php');

// Create an object (instance) of the DbConnector
$connector = new DbConnector();

// Execute the query to retrieve articles
$result = $connector->query('SELECT ID,title,tagline FROM news ORDER BY ID DESC LIMIT 0,5');
// Get an array containing the results.
// Loop for each item in that array
while ($row = $connector->fetchArray($result)){
$sql = $connector->query("SELECT ID, user FROM users WHERE '".$row[author]."' = ID");
while (
$rowauth = $connector->fetchArray($sql)){
echo
'<h3>';
echo
$row['title'];
echo
'</h3>';
echo
'<p>';
echo
$rowauth['user'];
echo
'</p>';
echo
'<p>';
echo
$row['thenews'];
echo
'</p><hr />';
}
}
?>
I have however, hit a wall and can't seem to work out a fix.

Any help is greatly appreciated.

Marzar
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 04:16 AM.





Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0