Search

45 posts by 5 authors in: Forums > CMS Builder
Last Post: May 19, 2010   (RSS)

By gcod - May 13, 2010

Hi Donna,

I applied your change and It didn't change much.
Though I realized that when I select an item in the country drop down, the page refresh and display the corresponding wines but the producer drop down now only show the producer that has wines in the country. Any idea why?

I'm still stuck for the text field search witht he price range drop down,Jason did you find anything new? I'll spend some time again tonight digging the forum to find some answers.

Any solution on how to not show by default all the wines and what I should put on the "Voir tous les vins" link to show them all?

Thanks for you help guys.
---------------------------------------------------
Webmaster, SEO Analyst, Social Media Analyst
www.gabrielcoder.com

Re: [gcod] Search

By Jason - May 14, 2010 - edited: May 14, 2010

Hi,

A couple of things for you to try.

First, if you want to search against the "title" field of all the tables, you need to change the name of your text field to "title" like this:
<input name="title" type="text"/>

Second, if you don't want any results to display when you first come to the page, try changing the code you use to output your wines to this:
<?php if($_REQUEST) : ?>
<?php foreach ($winesRecords as $record): ?>
<tr>
<td class="<?php if ($record['couleur'] == 'Blanc'): ?>white<?php endif; ?><?php if ($record['couleur'] == 'Rouge'): ?>red<?php endif; ?><?php if ($record['couleur'] == 'Rosee'): ?>rosee<?php endif; ?>">&nbsp;</td>
<td><?php echo $record['producer'] ?></td>
<td><?php echo $record['page_title'] ?></td>
<td><?php echo $record['country'] ?></td>
<td><?php echo $record['year'] ?></td>
<td><?php echo $record['origin'] ?></td>
<td><a href="<?php echo $record['_link'] ?>"><img src="/images/more.png" width="95" height="28" alt="Voir vin"/></a></td>
</tr>
<?php endforeach ?>
<?php endif ?>

This code should also display all the wines if a user clicks the ""Voir tous les vins" field.

The last problem is that you say you want to search against the region, country,wines,producer,year, and cepage tables, but when you output information, you only output records that come from the wines table. Are you going to change that, or do you only want to display wines?

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Search

By gcod - May 14, 2010

Hi Jason,

In the example you gave me the name of the input is the same as the one I putted. Not sure what you meant by that. Did you mean this?

<input name="title" type="text"/>

Because this doesn't work.

For the results to not show if a search is not done your <?php if($_REQUEST) : ?> is perfect, thanks.

The search only show wines; the region, country, producer, year, cepage tables are used in the wine section (as drop downs).

When I do a search I'd like to display all the wines that has the keyword in any of those table.

Right now it's working but my drop down (what I call the drop down search) is affected by the search and only display the value that fit the previous search.

Do you have an idea how to fix that?

Thanks.
---------------------------------------------------
Webmaster, SEO Analyst, Social Media Analyst
www.gabrielcoder.com

Re: [gcod] Search

By Jason - May 14, 2010

Hi,

Yes, you're right. Sorry about the typo.

Try replacing the code where you select your records at the top of your file with this:
<?php
require_once "/home/jeftay6/vinsbalthazard.com/cmsAdmin/lib/viewer_functions.php";

list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
));
$productsRecord = @$productsRecords[0];

list($listes_de_produitsRecords, $listes_de_produitsMetaData) = getRecords(array(
'tableName' => 'listes_de_produits',
));
$listes_de_produitsRecord = @$listes_de_produitsRecords[0];

$where = "";

if(@$_REQUEST['title']){
$where="region=".mysql_escape($_REQUEST['title'])." OR country=".mysql_escape($_REQUEST['title'])." OR producer=".mysql_escape($_REQUEST['title'])." OR year=".mysql_escape($_REQUEST['title'])." OR cepage=".mysql_escape($_REQUEST['title'])." OR page_title=".mysql_escape($_REQUEST['title']);
}

list($winesRecords, $winesMetaData) = getRecords(array(
'tableName' => 'wines',
'where' => $where,
'allowSearch' =>false,
));
list($producersRecords, $producersMetaData) = getRecords(array(
'tableName' => 'producers',
'allowSearch' => false,
));

list($yearRecords, $yearMetaData) = getRecords(array(
'tableName' => 'year',
'allowSearch' => false,
));

list($cepageRecords, $cepageMetaData) = getRecords(array(
'tableName' => 'cepage',
'allowSearch' => false,
));

list($countryRecords, $countryMetaData) = getRecords(array(
'tableName' => 'country',
'allowSearch' => false,
));

list($regionRecords, $regionMetaData) = getRecords(array(
'tableName' => 'region',
'allowSearch' => false,
));

list($price_rangeRecords, $price_rangeMetaData) = getRecords(array(
'tableName' => 'price_range',
'allowSearch' => false,
));

$page = 'produits';

?>


The code that we see here:
if(@$_REQUEST['title']){
$where="region=".mysql_escape($_REQUEST['title'])." OR country=".mysql_escape($_REQUEST['title'])." OR producer=".mysql_escape($_REQUEST['title'])." OR year=".mysql_escape($_REQUEST['title'])." OR cepage=".mysql_escape($_REQUEST['title'])." OR page_title=".mysql_escape($_REQUEST['title']);
}

is where we create the list of fields that we're doing our search on. You may need to change some of the names to match the names in your database.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Search

By gcod - May 14, 2010

Jason,

it doesn't seems to work.

Added your line of code (plus the wines) and change the form name to "title" and I get an error:

MySQL Error: Unknown column 'cepage' in 'where clause'

The drop down search doesn't work any more.

I attached my page.
---------------------------------------------------
Webmaster, SEO Analyst, Social Media Analyst
www.gabrielcoder.com
Attachments:

produits_002.php 8K

Re: [gcod] Search

By Jason - May 14, 2010

Hi,

What are the names of all of the fields in the wines section? The problem here is that cepage is either not a field or it has a different name.

Let me know.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Search

By gcod - May 14, 2010

I removed cepage and wines (wine gave the same error as cepage) a search with a year works (try 2008), but if I enter a producer name (one word or multiple) or country or a region the page crash.

For portugal for exemple:
MySQL Error: Unknown column 'portugal' in 'where clause'
---------------------------------------------------
Webmaster, SEO Analyst, Social Media Analyst
www.gabrielcoder.com

Re: [gcod] Search

By Jason - May 14, 2010

Try change where you're getting product records like this:

list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'allowSearch'=>false,
));


Also replace where we create our $where variable with this:

$where = "";

if(@$_REQUEST['title']){
$where="region='".mysql_escape($_REQUEST['title'])."' OR country='".mysql_escape($_REQUEST['title'])."' OR producer='".mysql_escape($_REQUEST['title'])."' OR year='".mysql_escape($_REQUEST['title'])."' OR cepage='".mysql_escape($_REQUEST['title'])."' OR wines='".mysql_escape($_REQUEST['title'])."'";
}


Give this a try. If it doesn't work, be sure to attach an updated copy of your code.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Search

By gcod - May 14, 2010

It's working only if I remove "cepage" (which right now is an empty table which would explain the error I suppose) and "wines" (which has a title).

I'd like the user to be able to type a wine name and find it.

If the user doesn't type the full producer name he won't get any result, is there a way to fix this? Display all the producer that has the keyword entered in their name (I'd like to have the same for wine too)

Last question, when you don't have any result can I display a message?

Thanks for your help and patience Jason.
---------------------------------------------------
Webmaster, SEO Analyst, Social Media Analyst
www.gabrielcoder.com