X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Drop down menu (https://forum.x-cart.com/showthread.php?t=6129)

Gibberish 01-20-2004 12:07 PM

Drop down menu
 
I need some help with a drop down menu I am trying to pull from the database.

What I am trying to do is generate a pull down menu from the brand field in the database based on if the categoryid on that same row as the brand matches the category currently being browsed.

Here is my select tag

Code:

<select name=brands>
{section name=brands loop=$brand_query}
<option {if $products[product].brand eq $brand_query[brands]}selected{/if}>{$brand_query[brands]}</option>
{/section}
</select>


Hee is my php

Code:

function brand_query() {
        $brand_query = "select $sql_tbl[products].brand where $sql_tbl[products].categoryid = $cat";

        }

$smarty->assign("main","specific_search.tpl")
?>



If someone could please make some suggestions or give me a push in the right direction it would be much appreciated.

I am going to keep working on it, and reading my php book.


Thanks.

laureon 01-20-2004 04:18 PM

take a look at one of my posts:

http://forum.x-cart.com/viewtopic.php?p=35218#35218

hope it helps you!

Gibberish 01-21-2004 07:52 AM

thank you for your reply. I put in your code but still same with not result on the drop down. Only thing that pops up is result.

At the bottom of your post you mention the serach.php needs to be altered, how do you mean? I put the query in the serach.php but is there something else that needs to be altered that I am missing?
I read through that topic too and tried a bunch of things but all came to the same result of no drop down being filled with the brand.

Gibberish 01-21-2004 11:58 AM

OK I got the drop downs to generate finally and now I have a simple question that I cannot find the answer too.

IF I put the select tags on the advanced_search.tpl they generate fine. If I put the same tags on my custom specific_search.tpl they do not generate. It is using the same form tag so it should be calling to the same php file right? What I am guessing is there is a file somewhere that I did not active the tpl or maybe php file.

Here is my customer/specific_search.php:

Code:

<?php

#
# $Id: search.php,v 1.50 2003/11/12 14:42:07 svowl Exp $
#


#
#  BRAND query
#
$brand_query = "SELECT distinct brand FROM $sql_tbl[products] WHERE forsale='Y' ORDER BY brand";

#
#  model query
#
$model_query = "SELECT distinct b_model FROM $sql_tbl[products] WHERE forsale='Y' ORDER BY b_model";

// assign query to smarty.
$brand = func_query($brand_query);
$model = func_query($model_query);
$smarty->assign("brand",$brand);
$smarty->assign("model",$model);

$smarty->assign("main","specific_search");


$smarty->display("customer/home.tpl");


?>




Here is my skin1/customer/main/specific_search.tpl:

Code:

{* $Id: specfic_search.tpl,v 1.19 2003/04/15 06:23:26 svowl Exp $ *}




<table width="100%" border="0" cellspacing="2">
  <form action="specific_search.php" name="specificsearch">
   
    <tr valign="top">
      <td height="40" colspan="6" align="left" valign="middle"><font class="CategoriesList" color="#FF6600">Specific
        Search:</font>
 <hr size=1 noshade width="100%" align="left"></td>
    </tr>
    <tr>
      <td width="12" height="45" valign="top"></td>
      <td width="212" align="center" valign="top" ><font class="SectionBody">Make:</font>
 
                        <select onChange="javascript:document.specificsearch.submit()" name="brand">
                                        <option value="">All</option>
                                {section name="brand" loop=$brand} 
                                        <option value="{ $brand[brand].brand }">{ $brand[brand].brand|escape }</option>       
                                {/section}
                        </select>
        </td>
      <td width="123" align="center" valign="top" > <font class="SectionBody">Model:</font>
 
        <select onChange="javascript:document.specificsearch.submit()" name="brand">
                                        <option value="">All</option>
                                {section name="brand" loop=$brand} 
                                        <option value="{ $brand[brand].brand }">{ $brand[brand].brand|escape }</option>       
                                {/section}
                        </select>  </td>
      <td width="93" align="center" valign="top" > <font class="SectionBody">Year:</font>
 
        <select onChange="javascript:document.specificsearch.submit()" name="brand">
                                        <option value="">All</option>
                                {section name="brand" loop=$brand} 
                                        <option value="{ $brand[brand].brand }">{ $brand[brand].brand|escape }</option>       
                                {/section}
                        </select>  </td>
      <td width="88" valign="top"></td>
      <td width="342" valign="center"><a href="javascript:specificsearch.submit()">{include
        file="buttons/search.tpl" style="button" type="input"}</a></td>
                </tr>
                </form>
          <tr>
      <td height="21" colspan="6" valign="top"><hr size=1 noshade></td>
    <tr>
      <td height="2"></td>
      <td ></td>
      <td ></td>
      <td ></td>
      <td></td>
      <td></td>

</table>



I think its a matter of linking the tpl to the php but I cannot see the problem.

Also I did name specific_search.tpl in the home_main.tpl.

Like I said I know the code works but I think the linking is bad and I cannot find where.

Gibberish 01-21-2004 09:30 PM

If someone could please post it would help me out alot.

Thanks.


All times are GMT -8. The time now is 10:32 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.