I am quite new to PHP and I appreciate any help here.
I have searched the web, and this forum and am becoming overwhelmed with different approaches to this.
Basically I'm creating an input form that will submit to a database. I need to then display that data in a table.
I'm creating a page where a client can input information about a vehicle he's selling. The webend users will then see a
formatted page with the information used to build it from the DB.
I know how to do the textfields etc.. But the check boxes have me a bit lost.
There will be maby 40-50 check boxes.
An admin side example for creating the vehicle listing would include:
Vehicle Options:
Power Steering [ ]
Heated Seats [ ]
Power Windows [ ]
etc..etc..
When the web user views the page with all the vehicle listings I want them to see this information formatted like:
Vehicle Options:
-Power Steering -Heated Seats -Power Windows
Should I create a field in the DB for each option?
One approach I heard was to have all the options in the DB as booleans. If the field has a true, then display it..
I donno.. I'm confused.
I can post some code from one approach I had. This takes all the options and adds them to one field for the record comma seperated.
I got thinking on this and it might be difficult to read this field and create the userend table using this data. I also have an "Edit" php page where the admin can edit the listing, Not sure if using this method would create way more work then it should.
Please choose Vehicle Options:<br />
Power Windows:<input type="checkbox" value="Power Windows" name="vehcOptions[]"><br />
Heated Seats:<input type="checkbox" value="Heated Seats" name="vehcOptions[]"><br />
Power Steering:<input type="checkbox" value="Power Steering" name="vehcOptions[]"><br />
<br>
----- on submit
foreach ($vehcOptions as $f) {
$queryvehcOptions = $queryvehcOptions.$f.",";
}
//The home type properties in this query is just from the original code I took this from...
$query = "INSERT INTO ListingsTable (VirtualTourId,ListingTitle,Description,Image,Price,MLSNumber,Location,Bedrooms,Bathrooms,SqFeet,Sold,vehcOptions) VALUES ('".$VirtualTourId."','".$ListingTitle."','".$Description."','".$Image."','".$Price."','".$MLSNumber."','".$Location."','".$Bedrooms."','".$Bathrooms."','".$SqFeet."','".$Sold."','".$queryvehcOptions."')";
Thanks for anyhelp, and I apologize for any vagueness.