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 "<p><header URL-Frame='content'
URL='news/view_article.php?id=$article_array[$i][1]'><bullet-image><b>$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

Reply via email to