close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Trying to visually separate data output, that should not show, if data field is empty

Thread began 2/19/2011 12:07 pm by Roxana | Last modified 2/24/2011 12:22 pm by Jason Byrnes | 3672 views | 13 replies |

Roxana

Trying to visually separate data output, that should not show, if data field is empty

This is not really a Dreamweaver question, but maybe someone could help me, so here it goes:

I have an online shop with catalogue and detail pages. The products offered consist of up to five components. Each of these components has its own data field. On the detail page they are listed in a column. On the catalogue page I do not want to waste vertical space and therefore list them separated by commas (this is how it used to be, until I split up the contents in different data fields to be able to list them in a column on the detail page).

So, when I insert a comma between the data fields, not as a surprise these commas will show up also for products, that have less than 5 components. This looks especially silly for products that don't list any components (5 commas in a row).

I tried forced space (with option+space), but the separation still does not look good.

Is there a way to maybe include the comma into the data set, or have a comma only be visible, if the following data field is not empty?

Sign in to reply to this post

Roxana

I tried this: <?php echo ","; echo $row_Recordset1['contents5']; ?>

But this will also show the comma, if the data field is empty.

Sign in to reply to this post

Roxana

Solution found :)

I just found the solution:

<?php if (!empty($row_Recordset1['contents2'])) echo ","; ?>

where the following field is <?php echo $row_Recordset1['contents2']; ?>

This way the comma will only show, if there is an entry in contents2. Same for all fields up to contents5.

Sign in to reply to this post

Roxana

Encouraged by my find, I now try to have a select menu not show, if the recordset is empty.

The menu disappears just like it should, but when I put that item in the cart, the item no. is missing, the price is zero. Only the description and quantity is passed on.

This is the code for he select menu with show if:
<?php if (!empty($row_rssizedefault['size'])) { // Show if recordset not empty ?>
<select name="SelectSize" id="SelectSize" onchange="showprice()">
<?php
do {
?>
<option value="<?php echo $row_rssizedefault['size_id']?>"<?php if (!(strcmp($row_rssizedefault['size_id'], $row_rssize['size']))) {echo "selected=\"selected\"";} ?>><?php echo $row_rssizedefault['size']?></option>
<?php
} while ($row_rssizedefault = mysql_fetch_assoc($rssizedefault));
$rows = mysql_num_rows($rssizedefault);
if($rows > 0) {
mysql_data_seek($rssizedefault, 0);
$row_rssizedefault = mysql_fetch_assoc($rssizedefault);
}
?>
</select>
<?php } // Show if recordset not empty ?>



The same happens, when I use this code as the first line instead:

<?php if (!empty($row_rssizedefault['size'])) { // Show if recordset not empty ?>

or <?php if ($totalRows_rssizedefault == 0) { // Show if recordset empty ?>


Does anyone know, what I have to change to make it work?

Sign in to reply to this post

Jason ByrnesWebAssist

imposible to tell what is wrong without seeing how the add to cart button is configured.


send a copy of your page please so i can look at the code.

Sign in to reply to this post

Roxana

Hi Jason,

Thank you for your help. I attached the detail page. It happens to be the same page, that I attached in the other thread.

The code you are looking for is from line 660 to 699.

Attached Files
detailwebassist.php.zip
Sign in to reply to this post

Jason ByrnesWebAssist

in the add to cart button, you have the Price, Article, version and size column set to get their values from the rspricelookup recordset.

the rspricelookup recordset relies on values from the SelectSize and SelectVersion form elements.


You would need to create another recordset that will return the correct price for items that do not have a size or version option and edit the add to cart code to use this recordset value instead.

php:
$ATC_itemPrice = floatval(($row_rspricelookup['price']!=""?$row_rspricelookup['price']:$row_rspriceNoSize['price']);// column binding
Sign in to reply to this post

Roxana

Almost there

Hi Jason,

Thank you for the code. I now understand, why the price and item no. weren't posted to the cart page. I used the same code for the item no..

In our situation, we have items without size and version option (for which the code worked just fine), but also items with size option and no version option, or the other way around.

I tried the code individually on each type of item, and it worked, but when I try to make it work for all items at the same time, then I have a PHP error (blank page). This is mainly, because I don't know how to put the code in sequence (I have no background knowledge of PHP).

What I am trying to tell the computer is: use rspricelookup, if there is no size info use rspriceNoSize, if there is no version info use rspriceNoVersion, if there is neither size nor version info use rsNoVersionNoSize.

The recordsets are tested and work.

This is what I tried as a first step, just to use rspriceNoVersionNoSize if rspriceNoSize does not return a price.
$ATC_itemPrice = floatval(($row_rspricelookup['price']!="")$row_rspricelookup['price']:$row_rspriceNoSize['price'])?$row_rspriceNoSize['price']:$row_rspriceNoVersionNoSize['price']);// column binding

Sign in to reply to this post

Jason ByrnesWebAssist

try using this code:

php:
$ATC_itemPrice = floatval(($row_rspricelookup['price']!="")?$row_rspricelookup['price']:(($row_rspriceNoSize['price']!="")?$row_rspriceNoSize['price']:$row_rspriceNoVersionNoSize['price']));// column binding
Sign in to reply to this post

Roxana

Thanks Jason,

I followed your lead and extended the code to also handle products with no version option, to pass on price and item no..

$ATC_itemPrice = floatval(($row_rspricelookup['price']!="")?$row_rspricelookup['price']:($row_rspriceNoSize['price']!=""?$row_rspriceNoSize['price']:($row_rspriceNoVersion['price']!=""?$row_rspriceNoVersion['price']:$row_rspriceNoVersionNoSize['price'])));// column binding

$ATC_itemarticle = "".$row_rspricelookup['item_no_long'] .""?$row_rspricelookup['item_no_long']:($row_rspriceNoSize['item_no_long']!=""?$row_rspriceNoSize['item_no_long']:($row_rspriceNoVersion['item_no_long']!=""?$row_rspriceNoVersion['item_no_long']:$row_rspriceNoVersionNoSize['item_no_long']));// column binding

It looks like it is working, but when I choose a certain size option and put it in the cart (that works), then I cannot choose another option of the same product. If I do so, the detail page will post the same as the first chosen option with that same price (the wrong price) regardless of my choice.

Your help already goes way beyond regular support, so please let me know, if you cannot help me any further from this point on.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...