Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in prove.php on line 11
include ('data.php');
$q = "SELECT f.*, SUM(b.ialt) AS ialt";
$q .= "FROM test_forestillinger f";
$q .= "LEFT JOIN test_billetter b";
$q .= "ON f.id = b.forestilling_id";
$q .= "GROUP BY f.id";
$q .= "ORDER BY f.id ASC";
$result = mysql_query($q);
while($row = mysql_fetch_array($result))
{
$id = $row['id'];
$lang = $row['lang'];
$dato = $row['dato'];
$antal_pladser = $row['antal_pladser'];
$pladser_taget = $row['ialt'];
echo "$id - $lang - $dato - $antal_pladser - $pladser_taget<br>";
}
Line 11 “while($row = mysql_fetch_array($result))”
Mine to data baser
ID i database forestillinger, er det samme tal kolonnen forestilling_id.
CREATE TABLE `billetter` (
`id` int(5) NOT NULL auto_increment,
`forestilling_id` int(2) NOT NULL default '0',
`navn` varchar(50) NOT NULL default '',
`voksen` int(2) NOT NULL default '0',
`born` int(2) NOT NULL default '0',
`ialt` int(2) NOT NULL default '0',
`dato` varchar(50) NOT NULL default '',
`email` varchar(50) NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
CREATE TABLE `forestillinger` (
`id` int(11) NOT NULL auto_increment,
`lang` varchar(50) NOT NULL default '',
`dato` varchar(50) NOT NULL default '',
`antal_pladser` int(3) NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;
Indlæg senest redigeret d. 27.08.2007 12:06 af Bruger #10441