Solved

Array results problem

Posted on 2011-02-21
2
240 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
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

828 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