Forum Moderators: coopster
Works pretty good since all the subcategory tables (like cars, pickup trucks, etc.) have the same column names - only the items in the tables change. I just can't seem to find any books or tutorials that assign a variable to a table (or even a database for that matter). Is there any problem with doing that?
$query="SELECT product FROM $displayTable";
$result=mysql_query($query);
while ($row=mysql_fetch_assoc($result)) {
echo $row['product']; echo "<br>";}
>> Is there any problem with doing that?
No, there isn't, however, you want to check to see if those tables exist before allowing them to go into a query otherwise you may get unexpected results. Also, to prevent from sql injection, you want to escape any variables that you are using in the query, as well. For this, you should use mysql_real_escape_string [php.net].
Good luck! :)
Nice to have you :)