Solved

Array results problem

Posted on 2011-02-21
2
241 Views
Last Modified: 2012-05-11
Hi;
This is the way I put my query results in an array

while($row=mysql_fetch_assoc($rsKeywords))
{
$results[]=$row ;
}
 
and this is my query


mysql_select_db($database_Remoteiran79, $Remoteiran79);
$query_rsArticles = "SELECT *, a.id AS id, s.type AS type, a.title AS title FROM rss_articles a LEFT JOIN rss_sources s ON (s.id = source_id)
WHERE  a.type!='trashed' AND (MATCH (a.title) AGAINST ('$keywords' IN BOOLEAN MODE))ORDER BY a.timestamp DESC";
$query_limit_rsArticles = sprintf("%s LIMIT %d, %d", $query_rsArticles, $startRow_rsArticles, $maxRows_rsArticles);
$rsArticles = mysql_query($query_limit_rsArticles, $Remoteiran79) or die(mysql_error());
$row_rsArticles = mysql_fetch_assoc($rsArticles);

When I want to print the array with

print_r ($results[5][keywords]);

I can get the result correctly

but when I try this

print_r ($results[keywords])

it does not return any results at all.  Would you please tell me what is wrong with this?

Thanks a lot
0
Comment
Question by:babak62
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
imaki06 earned 500 total points
ID: 34949100
$results[5][keyword] does get value of column keyword from row 5.
$results[keyword] tries to get row keyword, which cannot be found.

If you want to get column keyword from each line, then use following syntax:
foreach ($results as &$resrow) {
    print_r ($resrow[keywords]);
}
0
 

Author Closing Comment

by:babak62
ID: 34949189
EXCELLENT Million thanks
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question