Hello , i have a question, --this isnt the whole script, its a section i cant figure out--
I have two tables, one could be called, cars, and another carlocations, all locations having an ID.
So a person searches the DB cars, and finds a car he likes. He clicks it to display more information about it. Then it says where you can buy the car.
Is what i want to do is list all the locations in carlocations, and then in cars, have a column called, locations.
When i INSERT a car into the table, in the locations column, i type all the ID numbers of all the locations that hold the car.
Ok, now when i INSERT the IDs, lets say I *try* 1, 6, 10, 11, and perhaps w/o the commas, just 1 6 10 11
Can i have PHP do something like this:
Code:
$SQL = "SELECT * FROM cars WHERE id LIKE '$carid'";
$result = @mysql_query($SQL) or die("Could not run query");
while($row = mysql_fetch_array($result))
{
$anotherSQL = "SELECT * FROM cars WHERE id LIKE '$carid'";
$result = @mysql_query($anotherSQL) or die("Could not run query");
echo("<a href="carsearch.php?locations=$locationid>$locatio nsname</a>
// -----PHP would then see spaces in between the numbers, and for each space, it continues the while loop, chaning $location to the number after the space. So technically it would be doing this.
Locatoin Name(would (ID =1)
Locatoin Name (ID =6)
Locatoin Name (ID =10)
Locatoin Name (ID =11)
I know a lot of variables wernt specified, but this is just to show how i would want it to work. Perhaps there is a better way, i just dont want to make 100 columns, each being: location1, location2, location3, and then in the colum it gives 1 number.
If there is anything that could work similar to this, please post, i think the design i said is probably not possible.
---Thanks