Array Problem !

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Array Problem !

    Hi

    Ich habe ein Problem mit einem Array.Ich möchte das hier erstmal kurz erläutern :

    So kommt der Array zu Stande:
    PHP Code:
    $query=mysql_query("SELECT * FROM table");
    $i=0;
    while(
    $row=mysql_fetch_array($query)) {
    $arrayid[$i]=$row[id];
    $array[$i][spalte1]=$row[spalte1];
    $array[$i][spalte2]=$row[spalte2];
    $array[$i][spalte3]=$row[spalte3];
    $i++;

    Dann läuft das ganze duch eine foreach Schleife :
    PHP Code:
    foreach($arrayid as $key=>$value) {
    echo 
    "$array[$key][spalte1]<br>";


    Aber anstatt den Wert von "spalte1" kommt immer nur "Array[spalte1]" zum Vorschein

    Kann mir bitte jemand sagen,was ich hier falsch gemacht habe ?

    Gruss
    Last edited by framix; 08-04-2003, 17:55.

  • #2
    wenn du mehrdimensionale array in strings packst, wirst du immer das problem haben.

    mache es ....
    PHP Code:
    // entweder so.
    // also ausserhalb des strings. (find ich sauberer)
    echo $array[$key][spalte1]."<br>";

    //oder mit {} einschliessen.
    echo "{$array[$key][spalte1]}<br>"
    nur so weiss php, dass das array weiter geht.
    INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


    Comment


    • #3
      Danke !
      Ist eigentlich auch ganz gut so

      Comment

      Working...
      X