[PHP] Help w/Array Roadblock ( mental )

2004-03-13 Thread Joey
As you can see by the below code, I have tried many ways to store DB values
to a multi-dimensional array and then print them out.
The problem is I am missing something somewhere.
As you can see at the bottom of the code I created an array and printed the
entire content of the array, but getting it from DB to array and dumping it
has me lost some where.
 
Any help appreciated
 
J
 
 
 
%
 
$dbconn = mysql_pconnect(localhost, joe, thepassword);
mysql_select_db(barfield, $dbconn);
 
$now=time();

 $query = select * from articles where ( {$now} BETWEEN startdate AND
enddate);

 
 $db_result = mysql_query($query, $dbconn);
 
$db_error  = mysql_error();
$db_rows   = mysql_num_rows($db_result);
 
while ($db_record  $db_rows) {
  
# -
METHOD1-

#   $article_array[1]=mysql_result($db_result,$db_record,articleid);
#  $article_array[2]=mysql_result($db_result,$db_record,title);
 
# -
METHOD2-

$article_array = array ( 
  array( id = mysql_result($db_result,$db_record,articleid)),
  array( title = mysql_result($db_result,$db_record,title))
  );
print Rec- . $db_record . mysql_result($db_result,$db_record,articleid)
. -- . mysql_result($db_result,$db_record,title) . br;
print ARec- . $article_array[$db_record]['id']. - .
$article_array[$db_record]['title']  . br;
$db_record++;
 
echo $db_record .  . $article_array['id'] .  .  $article_array['title']
. br;
 
 }
 
echo =Old==br;
for($i=0;$i=count($article_array);$i++) {
  echo Record Number =  . $i . ;
echo ID:  . $article_array[$i][0] .    Title: 
.$article_array[$i][1] . br;
#echo pheader URL-Frame='content'
URL='news/view_article.php?id=$article_array[$i][1]'bullet-imageb$artic
le_array[$i][2]/b/header;
#echo fullstory URL-Frame = 'content'
URL='news/view_article.php?id=$article_arra[$i][1]'Full
story/fullstory/p;
}
 
 
echo =New==br;
for($i=0;$i=count($article_array);$i++) {
print $article_array[$i]['id'];print (##);print
$article_array[$i]['title'] . br;
}
 
 
 

echo =The Below Works Perfect==br;
 
$animals = array (
  array ( name = Mike,
type = dog,
color = Blue,
age = 7 ),
  array ( name = Bob,
type = cat,
color = brown,
age =7 ),
  array ( name = Joe,
type = squirrel,
color = green,
age =2 ),
  array ( name = Jay,
type = cow,
color = pink,
age = 5 )
 );
 
print $animals[0][type];print (br);print $animals[0][color];
echo ===br;
 
for($i=0;$i=count($animals);$i++) {
print $animals[$i][type];print (---);print $animals[$i][color] .
br;
}
 

%

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



Re: [PHP] Help w/Array Roadblock ( mental )

2004-03-13 Thread Robert Cummings
On Sat, 2004-03-13 at 04:35, Joey wrote:
 As you can see by the below code, I have tried many ways to store DB values
 to a multi-dimensional array and then print them out.
 The problem is I am missing something somewhere.
 As you can see at the bottom of the code I created an array and printed the
 entire content of the array, but getting it from DB to array and dumping it
 has me lost some where.
  
 Any help appreciated

To help understand if your array building is wrong, or your attempt to
output the array. Try using

print_r( $array );

To output the array to see it's structure. If you are viewing this in
your browser then it is better to do the following:

echo 'pre'.\n;
print_r( $array );
echo '/pre'.\n;

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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