DBookatay Posted February 7, 2008 Share Posted February 7, 2008 I am working on a script that allows you to compare checked items, (like on a lot of commerce sites) and I finally was able to figure out the java end of it, now I need some assistance with the php end. When items are selected and the button is pressed, it takes the item numbers and sends them to compare.php and seperated each item with a comma (http://www.carcityofdanbury.com/compare.php?CL=15933,15959,15931), now how do I seperate the numbers, and make it echo for each item? Here is what I have for 1 item number: <? $query = "select * from Inventory where stock = '{$_GET['CL']}'"; $result = mysql_query($query); $row = mysql_fetch_array($result); { $category = $row['category']; $stock = $row['stock']; $vehicle = "'".substr($row['year'], -2)." ".$row['make']." ".$row['model']." ".$row['trim']; if ($row['body'] == "SUV") { $body = $row['doors'].' Sport Utility'; } else { $body = $row['doors'].' '.$row['body']; } $passengers = $row['passengers']; $mileage = number_format($row['mileage']); if($row['trans_type']); switch($row['trans_type']){ case 'Automatic': $tranny = $row['trans_speed'].' Automatic'; break; case 'Tiptronic': $tranny = $row['trans_speed'].' <a href="#" onclick="return hs.htmlExpand(this, { contentId: \'Tiptronic\' } )">Tiptronic</a>'; break; case 'Manual': $tranny = $row['trans_speed'].' Manual'; break; } if ($row['engine_sub']) { $engine = $row['engine_liters'].' liter '.$row['engine_sub'].' '.$row['engine_cylinders']; } else { $engine = $row['engine_liters'].' liter '.$row['engine_cylinders']; } if($row['drivetrain']); switch($row['drivetrain']){ case 'Front Wheel Drive': $drivetrain = 'Front Wheel Drive'; break; case 'Rear Wheel Drive': $drivetrain = 'Rear Wheel Drive'; break; case 'All Wheel Drive': $drivetrain = 'All Wheel Drive'; break; case '4 x 4': $drivetrain = '4 x 4'; break; case 'Quattro': $drivetrain = 'All Wheel Drive'; break; } $fuel = $row['fuel']; $colors = $row['color_exterior'].' / '.$row['color_interior']; if ($row['price_asking'] == "0") {$price = "Just Arrived! CALL NOW";} else {$price = "$".number_format($row['price_asking']);} unset ($features); $features = array(); foreach ($row as $feature => $value) { if (substr($feature, 0,== "feature_") { if ($feature == "feature_AC") {if ($value == "x") {$features[] = "Air Conditioning</li>";}} if ($feature == "feature_PW") {if ($value == "x") {$features[] = "Power Windows</li>";}} if ($feature == "feature_PDL") {if ($value == "x") {$features[] = "Power Door Locks</li>";}} if ($feature == "feature_PM") {if ($value == "x") {$features[] = "Power Mirrors</li>";}} if ($feature == "feature_CC") {if ($value == "x") {$features[] = "Cruise Control</li>";}} if ($feature == "feature_SR") {if ($value == "x") {$features[] = "Sunroof</li>";}} if ($feature == "feature_LS") {if ($value == "x") {$features[] = "Leather Seats</li>";}} if ($feature == "feature_PS") {if ($value == "x") {$features[] = "Power Seat(s)</li>";}} if ($feature == "feature_HFS") {if ($value == "x") {$features[] = "Heated Front Seats</li>";}} if ($feature == "feature_HRS") {if ($value == "x") {$features[] = "Heated Rear Seats</li>";}} if ($feature == "feature_TW") {if ($value == "x") {$features[] = "Tilt Steering Wheel</li>";}} if ($feature == "feature_TCW") {if ($value == "x") {$features[] = "Telescoping Wheel</li>";}} if ($feature == "feature_KE") {if ($value == "x") {$features[] = "Keyless Entry</li>";}} if ($feature == "feature_TRS") {if ($value == "x") {$features[] = "Third Row Seating</li>";}} if ($feature == "feature_RS") {if ($value == "x") {$features[] = "Remote Start</li>";}} if ($feature == "feature_SP") {if ($value == "x") {$features[] = "Snow Plow</li>";}} if ($feature == "feature_RR") {if ($value == "x") {$features[] = "Roof Rack</li>";}} if ($feature == "feature_AW") {if ($value == "x") {$features[] = "Alloy Wheels</li>";}} if ($feature == "feature_FL") {if ($value == "x") {$features[] = "Fog Lights</li>";}} if ($feature == "feature_BL") {if ($value == "x") {$features[] = "Bed Liner</li>";}} if ($feature == "feature_HID") {if ($value == "x") {$features[] = "H.I.D Lights</li>";}} if ($feature == "feature_PG") {if ($value == "x") {$features[] = "Privacy Glass</li>";}} if ($feature == "feature_TP") {if ($value == "x") {$features[] = "Tow Package</li>";}} if ($feature == "feature_GPS") {if ($value == "x") {$features[] = "GPS System</li>";}} if ($feature == "feature_NS") {if ($value == "x") {$features[] = "Navigation System</li>";}} if ($feature == "feature_DVD") {if ($value == "x") {$features[] = "DVD System</li>";}} if ($feature == "feature_TA") {if ($value == "x") {$features[] = "Theft Alarm</li>";}} if ($feature == "feature_ABS") {if ($value == "x") {$features[] = "Anti-Lock Brakes</li>";}} if ($feature == "feature_FAB") {if ($value == "x") {$features[] = "Dual Front Airbags</li>";}} if ($feature == "feature_SCF") {if ($value == "x") {$features[] = "Side Curtin Airbags (F)</li>";}} if ($feature == "feature_SCR") {if ($value == "x") {$features[] = "Side Curtin Airbags (R)</li>";}} if ($feature == "feature_DCC") {if ($value == "x") {$features[] = "Dual Climate Control</li>";}} if ($feature == "feature_PAP") {if ($value == "x") {$features[] = "Power Adjustable Pedals</li>";}} if ($feature == "feature_MS") {if ($value == "x") {$features[] = "Memory Seats(s)</li>";}} if ($feature == "feature_OS") {if ($value == "x") {$features[] = "OnStar</li>";}} if ($feature == "feature_HL") {if ($value == "x") {$features[] = "HomeLink</li>";}} } } if (!$features) {$features_string = ' ';} else {$features_string = implode('<li class="compFtrs">', $features);} echo ' <td class="compOff" onmouseout="this.className=\'compOff\'" onmouseover="this.className=\'compOver\'"> <div align="center"> <table cellpadding="3" cellspacing="3"> <tr> <td><a href="include/popups/balloon.php?view=Pics&stock='.$stock.'&p=1" onclick="return hs.htmlExpand(this, { contentId: \'highslide-html\', objectType: \'ajax\', objectWidth: 800, objectHeight: 800} )" class="highslide"><img src="inventory/'.$category.'/'.$stock.'s.jpg" /></a></td> <td><a href="include/popups/balloon.php?view=Pics&stock='.$stock.'&p=2" onclick="return hs.htmlExpand(this, { contentId: \'highslide-html\', objectType: \'ajax\', objectWidth: 433, objectHeight: 325} )" class="highslide"><img src="inventory/'.$category.'/'.$stock.'_2s.jpg" /></a></td> </tr> <tr> <td><a href="include/popups/balloon.php?view=Pics&stock='.$stock.'&p=3" onclick="return hs.htmlExpand(this, { contentId: \'highslide-html\', objectType: \'ajax\', objectWidth: 433, objectHeight: 325} )" class="highslide"><img src="inventory/'.$category.'/'.$stock.'_3s.jpg" /></a></td> <td><a href="include/popups/balloon.php?view=Pics&stock='.$stock.'&p=4" onclick="return hs.htmlExpand(this, { contentId: \'highslide-html\', objectType: \'ajax\', objectWidth: 433, objectHeight: 325} )" class="highslide"><img src="inventory/'.$category.'/'.$stock.'_4s.jpg" /></a></td> </tr> </table> <table width="100%"> <tr><td class="compTitle">'.$vehicle.'</td></tr> <tr><td class="compSpec">'.$body.'</td></tr> <tr><td class="compSpec">'.$passengers.'</td></tr> <tr><td class="compSpec">'.$mileage.'</td></tr> <tr><td class="compSpec">'.$tranny.'</td></tr> <tr><td class="compSpec">'.$engine.'</td></tr> <tr><td class="compSpec">'.$drivetrain.'</td></tr> <tr><td class="compSpec">'.$fuel.'</td></tr> <tr><td class="compSpec">'.$colors.'</td></tr> <tr><td class="compPrc">'.$asking.'</td></tr> <tr><td class="compFtrs"><ul><li class="compFtrs">'.$features_string.'</ul></td></tr> </table> </div> </td>'; } ?> Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted February 7, 2008 Share Posted February 7, 2008 <?php $numbers = explode(',', $_GET['CL']); foreach($numbers as $number){ echo $number . "<br>\n"; } ?> Quote Link to comment Share on other sites More sharing options...
DBookatay Posted February 7, 2008 Author Share Posted February 7, 2008 Where does that go, before any other code, or at the "echo" part? Quote Link to comment Share on other sites More sharing options...
Northern Flame Posted February 7, 2008 Share Posted February 7, 2008 well what do you want to use the number for? i thought you just wanted to echo them. if all you want to do is echo them, you can insert this code anywhere where you want to echo the numbers, if you want to store them as variables for future use, let me know and ill do my best to help you Quote Link to comment Share on other sites More sharing options...
DBookatay Posted February 7, 2008 Author Share Posted February 7, 2008 Ok, I understand this: foreach($numbers as $number){ echo ' <td class="compOff" onmouseout="this.className=\'compOff\'" onmouseover="this.className=\'compOver\'"> <div align="center"> <table cellpadding="3" cellspacing="3"> <tr> <td><a href="include/popups/balloon.php?view=Pics&stock='.$stock.'&p=1" onclick="return hs.htmlExpand(this, { contentId: \'highslide-html\', objectType: \'ajax\', objectWidth: 800, objectHeight: 800} )" class="highslide"><img src="inventory/'.$category.'/'.$stock.'s.jpg" /></a></td> <td><a href="include/popups/balloon.php?view=Pics&stock='.$stock.'&p=2" onclick="return hs.htmlExpand(this, { contentId: \'highslide-html\', objectType: \'ajax\', objectWidth: 433, objectHeight: 325} )" class="highslide"><img src="inventory/'.$category.'/'.$stock.'_2s.jpg" /></a></td> </tr> <tr> <td><a href="include/popups/balloon.php?view=Pics&stock='.$stock.'&p=3" onclick="return hs.htmlExpand(this, { contentId: \'highslide-html\', objectType: \'ajax\', objectWidth: 433, objectHeight: 325} )" class="highslide"><img src="inventory/'.$category.'/'.$stock.'_3s.jpg" /></a></td> <td><a href="include/popups/balloon.php?view=Pics&stock='.$stock.'&p=4" onclick="return hs.htmlExpand(this, { contentId: \'highslide-html\', objectType: \'ajax\', objectWidth: 433, objectHeight: 325} )" class="highslide"><img src="inventory/'.$category.'/'.$stock.'_4s.jpg" /></a></td> </tr> </table> <table width="100%"> <tr><td class="compTitle">'.$vehicle.'</td></tr> <tr><td class="compSpec">'.$body.'</td></tr> <tr><td class="compSpec">'.$passengers.'</td></tr> <tr><td class="compSpec">'.$mileage.'</td></tr> <tr><td class="compSpec">'.$tranny.'</td></tr> <tr><td class="compSpec">'.$engine.'</td></tr> <tr><td class="compSpec">'.$drivetrain.'</td></tr> <tr><td class="compSpec">'.$fuel.'</td></tr> <tr><td class="compSpec">'.$colors.'</td></tr> <tr><td class="compPrc">'.$asking.'</td></tr> <tr><td class="compFtrs"><ul><li class="compFtrs">'.$features_string.'</ul></td></tr> </table> </div> </td>'; } but what about the call: $query = "select * from Inventory where stock = '{$_GET['CL']}'"; How do I handle that? Quote Link to comment Share on other sites More sharing options...
DBookatay Posted February 7, 2008 Author Share Posted February 7, 2008 $numbers = explode(',', $_GET['CL']); foreach($numbers as $number){ $query = "select * from Inventory where stock = '{$number}'"; $result = mysql_query($query); $row = mysql_fetch_array($result); { Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.