How do i dynamically populate a drop down menu from one of my fields

19 posts by 4 authors in: Forums > CMS Builder
Last Post: July 16, 2009   (RSS)

By blillie - July 10, 2009

Okay, i think we're getting there now. If you go to:

www.fanmarketplace.com/finddeals2.php

you'll see that it isn't just putting the categories in there now, it's putting them in for each time they're used. Also, if i select one it just pulls up everything on the listings page and doesn't seem to actually work.

Can you see what I'm talking about?

thx

Brian

By blillie - July 14, 2009

I've attached a screenshot for you to review and hopefully answer your question... i did what you said but they are still repeating.
Attachments:

screen-shot.jpg 131K

Re: [blillie] How do i dynamically populate a drop down menu from one of my fields

By ross - July 14, 2009

Hi billie

Could you post an up to date copy of finddeals2.php for us? Just attach it as a file instead of pasting the code into a post (this makes it much easier to read).

I know you are very close on this one so it's probably just one more adjustment.

Post that template though and we'll go from there. Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] How do i dynamically populate a drop down menu from one of my fields

By blillie - July 15, 2009

Here is the file.

thx

Brian
Attachments:

finddeals2_001.php 12K

Re: [blillie] How do i dynamically populate a drop down menu from one of my fields

By Damon - July 15, 2009

Hi Brian,

It looks like you have working now here:
www.fanmarketplace.com/finddeals.php


Here is the code I came up with:

<?php foreach ($categoryRecords as $record):
$productCategory[] = $record['category'];
endforeach;
?>
<?php $productCategory = array_unique($productCategory); ?>

<select name="category_match">
<?php foreach ($productCategory as $record): ?>
<option value="<?php echo htmlspecialchars($record) ?>"><?php echo htmlspecialchars($record) ?></option>
<?php endforeach; ?>
</select>


It grabs all the product categories and puts them into an array. Next is removes duplicate category names and then outputs in your select list.

If you are still having any issues with this, send us an email to support@interactivetools.com with your login details (URL, username and password) so we can help. Dont' t post login details here.
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Damon] How do i dynamically populate a drop down menu from one of my fields

By blillie - July 15, 2009

That worked great!!! Thx

One more quick question that hopefully is an easy fix... if you look at the sidebar navigation it lists the categories as links... can you help me with some code to have that automatically populate instead of me having to manually put them in....

I've attached the file that holds the code for that area of the website.

thx

Brian
Attachments:

categorynav.php 5K

Re: [blillie] How do i dynamically populate a drop down menu from one of my fields

By ross - July 16, 2009

Hi Brian

Glad that worked :).

To get it going with links, you basically use the same code. You can just take out the <select> and </select> tags then change the <option> into an <href>

Give it a shot and let me know how you make out :).
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Re: [ross] How do i dynamically populate a drop down menu from one of my fields

By blillie - July 16, 2009

Worked like a charm!

thx