Steerpike

msg:3644641 | 12:16 pm on May 8, 2008 (gmt 0) |
PHP has inbuilt functions called mysql_list_tables and mysql_list_fields that you can use to assemble the dropdowns.
|
jatar_k

msg:3644651 | 12:25 pm on May 8, 2008 (gmt 0) |
the basics are you grab the data from your mysql database and then loop through them using mysql_fetch_array or a similar function. Then as you loop through you can output your values from your database and your html together this is a good place to start Basics of extracting data from MySQL using PHP [webmasterworld.com]
|
Sarah Atkinson

msg:3644814 | 3:33 pm on May 8, 2008 (gmt 0) |
I just did one of these this week. Basicly you do what Jatar said: here's my code:
<ul> <?php include "db.inc.php"; $sql = "SELECT DISTINCT Make FROM table "; $makeresults=@mysql_query($sql); if(!$makeresults){ exit('<p>Error with Query...Error:' . mysql_error() . '</p>'); } while($makerow=mysql_fetch_array($makeresults)){ $Make=$makerow['Make']; echo "<li><a href=\"http://www.yoursite.com/yourpage.php?Make=" . $Make . "\" class=\"class\">". $Make. "</a>\n"; echo '<ul>'; $sql2 = "SELECT DISTINCT Model FROM table WHERE Make='$Make'"; $modelresults=@mysql_query($sql2); if(!$modelresults){ exit('<p>Error with Query...Error:' . mysql_error() . '</p>'); } while($modelrow=mysql_fetch_array($modelresults)){ $Model=$modelrow['Model']; echo "<li><a href=\"http://www.yoursite.com/yourpage.php?MakeModel=". $Make . '-' . $Model. "\">$Model</a></li>\n"; } echo "</ul></li>"; } ?> </ul>
I replaced some of the identifying variables but I think you can get the idea. It populates a list of "makes" in stock and gives each one a sublist of their models. [edited by: jatar_k at 6:29 pm (utc) on May 8, 2008] [edit reason] added some line breaks [/edit]
|
Sarah Atkinson

msg:3644817 | 3:35 pm on May 8, 2008 (gmt 0) |
oh and to make it pull down I used a Pop-menu using css and lists. This gave me greater control on looks then just a regular jump menu would
|
Spiceydog

msg:3644865 | 4:06 pm on May 8, 2008 (gmt 0) |
That is a little bit to much for me to understand... Do you think you could post the entire page so I could understand what things did? Like $sql2 what is that? And, I am not really sure how the CSS would go... maybe you could post your css as well? [edited by: Spiceydog at 4:06 pm (utc) on May 8, 2008]
|
|