Search

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

By Jason - May 14, 2010

Hi,

First, what is that name of the field where you store the wine's name?

Second, to search a partial name for a producer, replace our $where string with this:

$where = "";

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


You can enter similar code to do a partial search on the wine's name.

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

The name of the field in the wines table that store the wine's name is "title".

The wines table still pose problem.

The code to search the partial name for producer works, thanks.

We're getting close.
---------------------------------------------------
Webmaster, SEO Analyst, Social Media Analyst
www.gabrielcoder.com

Re: [Jason] Search

By gcod - May 17, 2010

Hi Jason,

It works! I can now search for a wine name.

For the second piece of code, where should I put it exactly? I'm getting the following error:
Notice: Use of undefined constant winesRecords - assumed 'winesRecords' in /home/jeftay6/vinsbalthazard.com/produits.php on line 151

I tried to put it between the <?php foreach ($winesRecords as $record): ?> and <?php endforeach ?> and I try between <?php if($_REQUEST) : ?> and the <?php endif ?>.

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

By Jason - May 17, 2010

Hi,

You would use it like this:

<?php if(!$winesRecords) : ?>
* Put No Records Message Here*
<?php else: ?>
<?php foreach($winesRecords as $record) : ?>
*Output Records Here*
<?php endforeach ?>
<?php endif ?>


That way you'll only go into the foreach loop if there are records in $wineRecords.

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 17, 2010

I still get the same message
Notice: Use of undefined constant winesRecords - assumed 'winesRecords' in /home/jeftay6/vinsbalthazard.com/produits.php on line 151

I can't find what I'm doing wrong, here is my code:
<?php if($_REQUEST) : ?>
<?php if(!winesRecords): ?>
<tr>
<td colspan="7" class="norecords">Aucun vin n'a été trouvé.</td>
</tr>
<?php else: ?>
<?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 ?>
<?php endif ?>

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

By Jason - May 17, 2010

Hi,

You're just missing a dollar sign ($)

Change:
<?php if(!winesRecords): ?>
to
<?php if(!$winesRecords): ?>

That should take care of the issue.
---------------------------------------------------
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 17, 2010

Nope it doesn't fix it.
---------------------------------------------------
Webmaster, SEO Analyst, Social Media Analyst
www.gabrielcoder.com

By Jason - May 17, 2010

Attach your latest copy of the .php file and I'll take a look at it.
---------------------------------------------------
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 17, 2010

Here you go.

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

produits_003.php 8K