Solved

Array results problem

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now