Re: Need help with sql
Someone another hint?
EDIT: K I fixed that problem but now my cars won't show
print "
<table width=100% border=6> <tr style='background:#cc9966'><th>Horses</th><th>Acceleration</th> <th>Handling</th><th>Speed</th><th>Shield</th><th>In Challenge?</th><th>Tune</th></tr>";
$q=$db->query("SELECT cp.*, ct.* FROM cars_playercars cp LEFT JOIN cars_types ct ON cp.cpcCAR=ct.carID WHERE cp.cpcPLAYER=$userid LIMIT $start, $cpp", $c);
$count=0;
$cars=array();
while($r=mysql_fetch_row($q))
{
$count++;
$acc=$r['cpcACCLV']*$r['carACC'];
$han=$r['cpcHANLV']*$r['carHAN'];
$spd=$r['cpcSPDLV']*$r['carSPD'];
$shd=$r['cpcSHDLV']*$r['carSHD'];
$q2=$db->query("SELECT * FROM challenges WHERE chCHRCAR={$r['cpcID']} chSTATUS='open'", $c);
if(mysql_num_rows($q2) == 1) { $challenge="<font color='red'>Yes</font>"; } else { $challenge="<font color='green'>No</font>"; }
print "<tr><td>{$r['carNAME']} </td> <td>Lv{$r['cpcACCLV']} ($acc)</td> <td>Lv{$r['cpcHANLV']} ($han)</td> <td>Lv{$r['cpcSPDLV']} ($spd)</td> <td>Lv{$r['cpcSHDLV']} ($shd)</td><td>$challenge</td> <td>[url='tune.php?id={$r[']Tune[/url]</td> </tr>";
$cars[$r['cpcID']]="{$r['carNAME']} - {$r['cpcACCLV']}/{$r['cpcHANLV']}/{$r['cpcSPDLV']}/{$r['cpcSHDLV']}";
}
if($count == 0) { print "<tr><th colspan=6>No Horses In Your stable</th></tr>"; }
print "</table>";
--
-- Table structure for table `cars_playercars`
--
CREATE TABLE IF NOT EXISTS `cars_playercars` (
`cpcID` int(11) NOT NULL auto_increment,
`cpcPLAYER` int(11) NOT NULL default '0',
`cpcCAR` int(11) NOT NULL default '0',
`cpcACCLV` int(11) NOT NULL default '0',
`cpcHANLV` int(11) NOT NULL default '0',
`cpcSPDLV` int(11) NOT NULL default '0',
`cpcSHDLV` int(11) NOT NULL default '0',
PRIMARY KEY (`cpcID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=169 ;
--
-- Dumping data for table `cars_playercars`
--
INSERT INTO `cars_playercars` (`cpcID`, `cpcPLAYER`, `cpcCAR`, `cpcACCLV`, `cpcHANLV`, `cpcSPDLV`, `cpcSHDLV`) VALUES
(168, 5, 1, 1, 1, 1, 1),
(167, 5, 1, 1, 1, 1, 1),
(166, 1, 1001, 1, 1, 1, 1),
(165, 1, 1, 1, 1, 1, 1);