Mathiis: MySQL Abfrage in Array

Beitrag lesen

$result->fetch
  $result->fetch()

Hallo,

ich habe es nun so gemacht:

  
error_reporting(E_ALL);	  
$firstweekday='20090209000001';  
	$lastweekday='20090213235959';	  
  
	$tmp = array();  
		$tmp[1] = array();  
		$tmp[2] = array();  
		$tmp[3] = array();  
		$tmp[4] = array();  
		$tmp[5] = array();  
		$tmp[6] = array();  
		  
$sql = "SELECT  
		UNIX_TIMESTAMP(termin_startdate) as weekday,  
		termin_id, termin_startdate, termin_enddate	  
		FROM weekplan_termin WHERE termin_fach 	= 2  
		AND termin_startdate  
		BETWEEN '".$firstweekday."' AND '".$lastweekday."'  
		ORDER by termin_startdate";  
$result = $db->query($sql);  
if (!$result) {  
    die ('Etwas stimmte mit dem Query nicht: '.$db->error);  
}  
echo 'Die Ergebnistabelle besitzt '.$result->num_rows." Datensätze<br />\n";  
		while($row = $result->fetch_row()) {  
   		$tmp[date("N",$row['termin_startdate'])][] = $row;  
		}  
	foreach ($tmp as $value){  
			print_r($value)."\n";  
	}  
	var_dump($result);	  

Ich bekomme die Meldung: Undefined index: termin_startdate
Ich bekomme zwar eine Ausgabe, aber es wird nicht richtig sortiert.

Array ( ) Array ( ) Array ( ) Array ( [0] => Array ( [0] => 1234162800 [1] => 1 [2] => 2009-02-09 08:00:00 [3] => 2009-02-09 11:00:00 ) [1] => Array ( [0] => 1234188000 [1] => 2 [2] => 2009-02-09 15:00:00 [3] => 2009-02-09 18:30:00 ) [2] => Array ( [0] => 1234252800 [1] => 3 [2] => 2009-02-10 09:00:00 [3] => 2009-02-10 12:00:00 ) [3] => Array ( [0] => 1234508400 [1] => 4 [2] => 2009-02-13 08:00:00 [3] => 2009-02-13 10:30:00 ) ) Array ( ) Array ( )

Es wird alles in einen "Tag" geschrieben und auch noch mitten drin.