Multi-select to display links and images

21 posts by 4 authors in: Forums > CMS Builder
Last Post: June 1, 2009   (RSS)

By Dave - July 30, 2008

It looks like you're getting the upgrade labels in the MySQL query and not the upgrade numbers like you want. Note that is you previously saved the values by name and then changed it the old values will still be stored until you resave that record.

Anytime a MySQL query isn't working the first thing to do is back up and print out the variables you're passing to it (or the query itself). Try this debug code:

print "<xmp>Product Record: ";
print_r($productsRecord);
print "</xmp>";

or

print "<xmp>a_upgrades: ";
print_r($productsRecord)['a_upgrades'];
print "</xmp>";

Another trick is to add this option which displays the SQL being executed:

'debugSql' => true,

Let me know if that reveals anything useful.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Multi-select to display links and images

By Kenny - July 30, 2008

Now I get:

SELECT SQL_CALC_FOUND_ROWS * FROM `cms_products` WHERE (num IN (2x3 Window, 3x4 Insulated Window, 4, 8, Extra Set of Doors, Framing Package - $1.75 per sq. ft., Heavy Duty Floor - $50.00 per 8, On-Site Build - Add 12%, Pressure Treated Floor - $100 per 8, Turbine)) ORDER BY dragSortOrder

I wasn't using dragSortOrder on the "upgrades" section so I put it in - same result.

I was using dragSortOrder on the "products" section so I took it out - no more mySql error!

Now where the features are supposed to be:

Upgrades: Notice: Undefined index: upgrades in /home/lelands/public_html/products/product2.php on line 136



My code there is:

<table border="0" cellpadding="3" cellspacing="3" width="100%" id="table42">
<tr>
<td bgcolor="#ED1C24"><b>
<font face="Arial" color="#FFFFFF">Name: <?php echo $productsRecord['name'] ?></font></b></td>
</tr>
<tr>
<td><font face="Arial" size="2">Description: <?php echo $productsRecord['description'] ?></font></td>
</tr>
<?php foreach ($relatedProductRecords as $record): ?>
<tr>
<td><font face="Arial" size="2"> Upgrades: <?php echo $record['upgrades'] ?><br/>
Price: <?php echo $record['price'] ?><br/></font></td>
</tr>
<?php endforeach ?>



My top of page code is the same as yesterday.

By Dave - July 30, 2008

I think we still need to get the product numbers in the "numIN (...)" part. Not sure why it's using labels and not nums.

For the "undefined index' error, is the field called 'upgrades' or 'a_upgrades'? Undefined index means it couldn't find that field in the record. You can try displaying all the fields in the record with this code to see what fields are available (or where the missing ones are):

<xmp><?php print_r($record); ?></xmp>

If it keeps giving errors feel free to email me FTP and CMS login details and I could take a look.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Multi-select to display links and images

By Kenny - July 30, 2008

That worked! No more errors!

Now one other little problem with the display: it groups them together into two different groups as a paragraph. How do I make them show up as a list in 1 column (leaving out blank spots for items that are unchecked)

I have:

<tr>
<td><?php foreach ($relatedProductRecords as $record): ?><font face="Arial" size="2"><?php echo $record['a_upgrades'] ?><br></font><?php endforeach ?></td>
</tr>



The sample output can be seen here:

http://www.lelandsindustries.com/products/product2.php?Metal-Buildings-3

By Dave - July 30, 2008

The multiple values are stored in a tab delimited list. So you could try this to get it into an array (list):

// note: replace table and variable names with the right ones for your site:
$labels = getListLabels('products', 'related_products', $productsRecord['related_products']);

Then
<?php echo join('<br/>', $labels); ?>

or
<?php foreach ($labels as $label): ?>
<?php echo $label ?><br/>
<?php endforeach ?>

hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [willbegood] Multi-select to display links and images

By Dave - June 1, 2009

Hi willbegood,

Can you attach the viewer page you are working on and post the error message (if any) you are getting? Thanks!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Multi-select to display links and images

By willbegood - June 1, 2009

Thanks, here is the file

here is the list : http://www.onsemobilisepourvous.com/client/caribbean_spirit_net/gmap3/test8.php

Clicking on one of the link go to the "detail.php" attached
Neither in test8.php (list) nor detail.php (detail page) i can make it work

In test8.php i can see only one linked data per entry
And in detail.php nothing.
Attachments:

detail.php 4K

Re: [willbegood] Multi-select to display links and images

By Dave - June 1, 2009

Hi willbegood,

Is this the same issue as this post?
http://www.interactivetools.com/forum/gforum.cgi?post=72137#72137

If so, let's continue the discussion over there. If it's a different issue just let me know.

Thanks!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Multi-select to display links and images

By willbegood - June 1, 2009

yes it's the same issue.