kleptik Posted December 9, 2006 Share Posted December 9, 2006 I have one table that has:"Vehicles" Car | Options -------------------- foo 2,3 (These options are added in CSV, from an array of check boxes upon "Adding" the vehicle initially)another table that has:"Vechicle Options:"ID | Interior-----------------1 | power windows2 | heated seats3 | cruise controlOn my page that displayes the vehicle information I want to display all the related options from the "Vehicle Options" table.I was thinking about an SQL select like:"SELECT `Interior` FROM `VehicleOptions` WHERE `ID`=9 and `ID`=8 and `ID`=7"But this isn't going to work. ;)Thanks for the help! Link to comment https://forums.phpfreaks.com/topic/30061-simple-echo-of-data-from-db-help/ Share on other sites More sharing options...
Destruction Posted December 9, 2006 Share Posted December 9, 2006 WHERE `ID` IN (9, 8, 7) Link to comment https://forums.phpfreaks.com/topic/30061-simple-echo-of-data-from-db-help/#findComment-138197 Share on other sites More sharing options...
kleptik Posted December 9, 2006 Author Share Posted December 9, 2006 Worked perfectly.. :) Thanks Dest. Link to comment https://forums.phpfreaks.com/topic/30061-simple-echo-of-data-from-db-help/#findComment-138200 Share on other sites More sharing options...
kleptik Posted December 9, 2006 Author Share Posted December 9, 2006 now another question on forming my PHP sql select.$VechOptions contains: 1,4,6,9,10,12,15I want to display it now.something like:$OptionsQuery = "SELECT 'Interior' FROM VehicleOptions WHERE 'ID' IN (".$VechOptions.")"; //Don't think this is correct.// Since this is going to just return 1 result, do I need to for loop it? like below $OptionsResult = $database->query($OptionsQuery); for ($i=0; $i<$OptionsResult->numRows(); $i++) { $OptionsAll = $result->fetchRow(DB_FETCHMODE_ASSOC,$i); $VechOptions = $OptionsAll['AllOptions']; }I want to then display kinda like:echo $VechOptions; // which would show something like: Power Windows Heated Seats Power Windows etc..--------Been trying something like this, just getting Object or Array returned. :([code]<?php $OptionsQuery = "SELECT 'Interior' FROM VehicleOptions WHERE 'ID' IN ($VechOptions)"; //SELECT `Interior` FROM `VehicleOptions` WHERE `ID` IN (9,6,4) $OptionsResult = $database->query($OptionsQuery); echo $OptionsResult;// for ($i=0; $i<$OptionsResult->numRows(); $i++) { $OptionsAll = $result->fetchRow(DB_FETCHMODE_ASSOC,$i); $VechOptions = $OptionsAll['AllOptions']; echo $VechOptions[0].' '.'<BR>'; }[/code] Link to comment https://forums.phpfreaks.com/topic/30061-simple-echo-of-data-from-db-help/#findComment-138205 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.