> Hi,
> Thanks for replying.

no probs...

>
> I have not worked with arrays much other than simple arrays like the $_get
> or $_post and the database ones...can you give me a another emample on how
> to do this please?
> like how to put my db into an array and then call each part....
>

sorry, i'm probably not the best person to give a full working example. my
code works for me, but it's a little sloppy. check the php manual. look-up
associative arrays.

lets see if i can't give you a quick example tho...

<?

$n = 0;
$result = mysql_query( "SELECT id, title, text, date FROM news ORDER BY date
DESC" );
while ($rows = mysql_fetch_array($result)) {
  if( $rows == "" ){
   continue;
  }
  extract( $rows );   ///extract our result into variables named after our
fields
  $content[id][$n] = $id;
  $content[title][$n] = $title;
  $content[text][$n] = $text;
  $content[date][$n] = $date;
  $n++; //increment our number for next time...
 }

//this next bit is sloppy coz i'm just gonna make it up for an example

print "<table>"
for( $c=0; $c<4; $c++ )   //4 coz there's 4 key fields
{
//print the id's
    print "<tr>";
    print "<td>ID</td>";
    for( $i=0; $i<$n; $i++ )
        print "<td>".$content[id][$i]."</td>";
    print "</tr>";
//print the titles
    print "<tr>";
    print "<td>TITLE</td>";
    for( $i=0; $i<$n; $i++ )
        print "<td>".$content[title][$i]."</td>";
    print "</tr>";
//print the text
    print "<tr>";
    print "<td>TEXT</td>";
    for( $i=0; $i<$n; $i++ )
        print "<td>".$content[text][$i]."</td>";
    print "</tr>";
//print the date
    print "<tr>";
    print "<td>DATE</td>";
    for( $i=0; $i<$n; $i++ )
        print "<td>".$content[date][$i]."</td>";
    print "</tr>";
}
print "</table>";

?>

like i said, this isn't the most glamorous way of doing it, and you really
should look this all up in the manual before trying it out. but if you run
this code (and you have a db to back it up) you should get a table with the
format i think your after...


>
> Thanks,
> -Ryan
>

no probs, hope my sloppy code helps you a little ;)

-skate-



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

Reply via email to