Justtechjobs.com Find a programming school near you






Online Campus Both


php-db | 2002091

Re: [PHP-DB] Can't see the results From: Jim Hunter (jim <email protected>)
Date: 09/06/02

Your problem seems to stem from the $content .= $row; $row is an Array and
you must use an index to get at any given value it holds. If you need all of
the values in $row, use the count() function to get the number of elements
(columns in this case), then loop through them adding them to $content along
with any separators (IE: commas or semi colons or spaces) etc. the code
might look like this:

$content = ""; // I like to make sure that the variable is always
initialized to something before I use it.

$num_results_cat = mysql_num_rows($result_cat);

for ($i=0; $i < $num_results_cat; $i++)
{
$row = mysql_fetch_array($result);
  $num_of_cols = count($row);
  for ($x=0; $x<$num_of_cols; $x++)
    {
      $content .= ", ".$row[$x];
    }
}

This will allow you to loop through every row in the query and add every
column to the $content variable.

Jim

-------Original Message-------

From: Wilmar Perez
Date: Friday, September 06, 2002 14:50:44
To: php-db mailing list
Subject: [PHP-DB] Can't see the results

Hello guys

Thanks to all those you helped me with y the question I made before (not a
valid MySQL result) it's working now.

Now, I want to display the result of my search with the following code:

if($code){

$query_cat = "select author.author_names || ' '|| author.author_surnames
as full_name from author, authorxcat
where authorxcat.cat_code = $code
and author.author_code = authorxcat.author_code"
or die($mysql_error());

$result_cat = mysql_query($query_cat);

$num_results_cat = mysql_num_rows($result_cat);

for ($i=0; $i < $num_results_cat; $i++)
{
$row = mysql_fetch_array($result);
$content .= $row;
/*
$content .= htmlspecialchars(stripslashes($row["author_names"]))
." ".htmlspecialchars(stripslashes($row ["author_surnames"]))."<br>";*/
}

}

But I just get the following:

ArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArray

I also tried to do it commenting the "$content .= $row;" and uncommenting
the lines that are commented in the code but I just get a blank page.

What am I doing wrong?

Thanks a lot for your help.
*******************************************************
Wilmar Pérez
Network Administrator
Library System
Tel: ++57(4)2105145
University of Antioquia
Medellín - Colombia
2002
*******************************************************



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

.