Page 10 of 15 FirstFirst ... 67891011121314 ... LastLast
Results 91 to 100 of 141

Thread: One more: Online Designer?

  1. #91
    jmarcv's Avatar
    jmarcv is offline Cranky Coder
    Join Date
    Jan 2005
    Posts
    354

    Default

    I'm Back! And so are you, it looks like?

    First of all, static html???? Say it aint so!

    #1
    You may want to get in the habit of throwing in something like this for debugging, so there are no surprises and 6 day head scratching:
    print "DEBUG: optn15 = ".$_POST["optn15"]."<BR>";
    -- or --
    print "DEBUG: background = ".$background ."<BR>";

    -- Your problem will be very obvious. You are assigning the # 415, for example to the background var. Thats great for the DB but it isnt a URL, now is it? You are assuming that is the issue, but poutting in a temp thing like that would make it plain as day, and you could move on.

    You need to have a hidden var to hold the URL also when you make the selection. We had a few stacked JS commands in the past to do this.
    Personally, rather than a confusing mess like that, I would rename 3bamboo.jpg to 415.jpg
    Then you could just do this:
    Code:
       <td align="center" valign="middle"><table width="350" height="200" border="0" align="center" cellpadding="0" cellspacing="0" background="http://www.rlhanson-online.com/designer/images/pics/backgrounds/thumbnails/<?php echo $background;?>.jpg">
    #2 you will need to go back and learn about PHP arrays and loops.
    Not seeing where this is done, I can say, review the sections on arrays.

    $pointconvert=array('8pt'->'421','10pt'->'422', .... etc);
    This sets up an associative array with points as the 'key' and DBcodes as the 'Value' so you can defibe it once and use it as a 'lookup'
    Each DB value of the array is 'associated' with a point size.
    Code:
    <input hidden name=SIZEcompanyNameConverted value="<?$pointconvert[$_POST['SIZEcompanyName']]?>">
    <input hidden name=SIZEaddressConverted value="<?$pointconvert[$_POST['SIZEaddress']]?>">
    .. Or, do it (ughhh!) the sloppy comprehensible way:
    Code:
    <input hidden name=SIZEcompanyNameConverted value="
    <?
    if ($_POST['SIZEcompanyName']=='8pt'){
        echo '421';
    } elseif($_POST['SIZEcompanyName']=='10pt'){
        echo '422';
    } elseif(...) {
        echo '...';
    }
    ?>">
    #3 You lost me? Hidden vars are how you 'collect' info and pass it to the next page. But you know that already? So is there something I missed?


    Hope that helps.

  2. #92
    rlhanson's Avatar
    rlhanson is offline Master Glow Jedi
    Join Date
    Aug 2007
    Location
    Chapman, Kansas
    Posts
    531

    Default

    I'm Back! And so are you, it looks like?
    I know, I've been away awhile! lol You know, life as it delivers it on it's terms and not mine!

    First of all, static html???? Say it aint so!
    It stinks to do it this way, but unfortunatley I am not equipped (yet!) to know how to modify the shopping cart code to get it to do what I want!

    In my fantasy world:
    I would have the shopping cart code say if $optnshtml = (value) then onclick would update the preview (id) with this...

    I would have the images associated with the value in the database so that I could put echo $optn2 and the image would display...

    Do you know how I could do that? Right now, when you input a product option you can hard code the image path, and then it shows a radio button with the image next to it, but assigns a value of 414 (for example).

    but for now, I am line by line coding every possible background image! Ugh!

    **also...when I create a hidden input on the images, I either couldn't get the background name to show in the shopping cart or it would only show the last image possible on the page... which is why I didn't pass hidden information to the next page...

    $pointconvert=array('8pt'->'421','10pt'->'422', .... etc);
    This sets up an associative array with points as the 'key' and DBcodes as the 'Value' so you can defibe it once and use it as a 'lookup'
    I like this - I could use the same concept for the images too - still a long way from arrays and loops though.

    #3 I finally have the preview working with this:

    PHP Code:
    <?php 
       $optn2 
    $_POST['optn2'];
    if (
    $optn2 == '414'
     {   
      echo 
    "<table width='325' height='200' border='0' align='center' cellpadding='0' cellspacing='0' background='designer/images/pics/backgrounds/3bamboo.jpg'>";
     }
    else if (
    $optn2 == '415')
     {
     echo 
    "<table width='325' height='200' border='0' align='center' cellpadding='0' cellspacing='0' background='designer/images/pics/backgrounds/9birchlake.jpg'>";
     }
     
    ?>
    Messy huh?!

    I am looking at your code and trying to read on arrays.

    My thinking is this:
    If a background is chosen, then display this page which has the preview table - but populate the preview tables' background image based on the 1st page's background selection.

    Just for your viewing pleasure, this is the code that the incproductbody.php page uses to display product options - if I could figure out how to assign the onclick events like I mentioned in my fantasy world then I could actually use my shopping cart pages to display the designer pages with options and have it update the preview table:
    PHP Code:
    <form method="post" name="tForm0" action="cart.php" onsubmit="return formvalidator0(this)" style="margin:0px;padding:0px;">
    <?php writehiddenvar('id'$rs['pId']);
     
    writehiddenvar('mode''add');
     
    writehiddenvar('frompage'str_replace('"''&quot;', @$thefrompage));
     print 
    '<input type="hidden" name="quant" id="qnt'.$Count.'x" value=""/>';
     print 
    '<div class="proddescription">';
     
    $shortdesc $rs[getlangid('pDescription',2)];
     if(@
    $shortdescriptionlimit=='') print $shortdesc; else print substr($shortdesc0$shortdescriptionlimit) . (strlen($shortdesc)>$shortdescriptionlimit '...' '');
     print 
    '</div>';
     
    $optionshavestock=true;
     
    $hasmultipurchase 0;
     if(
    is_array($prodoptions)){
      if(
    $noproductoptions==TRUE){
       
    $hasmultipurchase=2;
      }else{
       if(
    $prodoptions[0]['optType']==&& @$noproductoptions!=TRUE$thestyle=''; else $thestyle=' width="100%"';
       
    $optionshtml displayproductoptions('<strong><span class="prodoption">','</span></strong>',$optdiff,$thetax,FALSE,$hasmultipurchase);
       if(
    $optionshtml!='') print '<div class="prodoptions"><table border="0" cellspacing="1" cellpadding="1"'.$thestyle.'>' $optionshtml '</table></div>';
       
    $rs['pPrice'] += $optdiff;
      }
     }    
    ?></form>

    What would you do - knowing how to code - to streamline it all?

    Thanks sooo much John-Marc!!!
    Last edited by rlhanson; 01-18-2009 at 12:29 PM. Reason: added also statement lol
    Thank you,
    Lynne Hanson
    RL Hanson-Online

  3. #93
    rlhanson's Avatar
    rlhanson is offline Master Glow Jedi
    Join Date
    Aug 2007
    Location
    Chapman, Kansas
    Posts
    531

    Default

    I found this within the incfunctions.php page....

    PHP Code:
    <?php //much more above this
    function displayproductoptions($grpnmstyle,$grpnmstyleend,&$optpricediff,$thetax,$isdetail,&$hasmulti){
     global 
    $rs,$prodoptions,$useStockManagement,$hideoptpricediffs,$pricezeromessage,$noprice,$OWSP,$xxPlsSel,$Count,$optionshavestock,$xxOpSkTx,$noshowoptionsinstock,$showinstock,$showtaxinclusive,$defimagejs,$multipurchasecolumns,$xxSelOpt,$xxClkHere,$startlink,$endlink;
     
    $optpricediff 0;
     
    $optionshtml '';
     
    $hasmulti FALSE;
     foreach(
    $prodoptions as $rowcounter => $theopt){
      
    $opthasstock=false;
      
    $sSQL='SELECT optID,'.getlangid('optName',32).','.getlangid('optGrpName',16).',' $OWSP 'optPriceDiff,optType,optFlags,optGrpSelect,optStock,optPriceDiff AS optDims,optDefault FROM options LEFT JOIN optiongroup ON options.optGroup=optiongroup.optGrpID WHERE optGroup=' $theopt['poOptionGroup'] . ' ORDER BY optID';
      
    $result mysql_query($sSQL) or print(mysql_error());
      if(
    $rs2=mysql_fetch_array($result)){
       if(
    abs((int)$rs2['optType'])==3){
        
    $opthasstock=true;
        
    $fieldHeight round(((double)($rs2['optDims'])-(int)($rs2['optDims']))*100.0);
        
    $optionshtml .= '<tr><td align="right" width="30%">' $grpnmstyle $rs2[getlangid('optGrpName',16)] . ':' $grpnmstyleend '</td><td align="left"> <input type="hidden" name="optn' $rowcounter '" value="' $rs2["optID"] . '" />';
        if(
    $fieldHeight != 1){
         
    $optionshtml .= '<textarea wrap="virtual" name="voptn' $rowcounter '" cols="' . (int)$rs2["optDims"] . '" rows="' $fieldHeight '">';
         
    $optionshtml .= $rs2[getlangid('optName',32)] . '</textarea>';
        }else
         
    $optionshtml .= '<input maxlength="255" type="text" name="voptn' $rowcounter '" size="' $rs2['optDims'] . '" value="' str_replace('"','&quot;',$rs2[getlangid('optName',32)]) . '" />';
        
    $optionshtml .= '</td></tr>';
       }elseif(
    abs((int)$rs2['optType'])==1){
        
    $optionshtml .= '<tr><td align="right" valign="baseline" width="30%">' $grpnmstyle $rs2[getlangid('optGrpName',16)] . ':' $grpnmstyleend '</td><td align="left"> ';
        do {
         
    $optionshtml .= '<input type="radio" style="vertical-align:middle" onclick="updateoptimage('.$Count.','.$rowcounter.','.($isdetail?'1':'0').',1);' . (($rs['pPrice']==&& @$pricezeromessage != '') || @$noprice==TRUE ?'dummyfunc':'updateprice' $Count) . '();" name="optn' $rowcounter '" ';
         if((int)
    $rs2['optDefault']!=0$optionshtml .= 'checked ';
         
    $optionshtml .= 'value="' $rs2['optID'] . '" /><span ';
         if(
    $useStockManagement && $rs['pStockByOpts']!=&& $rs2['optStock'] <= 0$optionshtml .= ' class="oostock" '; else $opthasstock=true;
         
    $optionshtml .= '>' $rs2[getlangid('optName',32)];
         if(@
    $hideoptpricediffs != TRUE && (double)($rs2['optPriceDiff']) != 0){
          
    $optionshtml .= ' (';
          if((double)(
    $rs2['optPriceDiff']) > 0$optionshtml .= '+';
          if((
    $rs2['optFlags']&1)==1)$pricediff = ($rs['pPrice']*$rs2['optPriceDiff'])/100.0;else$pricediff $rs2['optPriceDiff'];
          if(@
    $showtaxinclusive===&& ($rs['pExemptions'] & 2)!=2$pricediff+=($pricediff*$thetax/100.0);
          
    $optionshtml .= FormatEuroCurrency($pricediff) . ')';
          if(
    $rs2['optDefault']!=0$optpricediff += $pricediff;
         }
         if(
    $useStockManagement && @$showinstock==TRUE && @$noshowoptionsinstock != TRUE && (int)$rs["pStockByOpts"] != 0$optionshtml .= str_replace('%s'$rs2['optStock'], $xxOpSkTx);
         
    $optionshtml .= '</span>';
         if((
    $rs2['optFlags'] & 4) != 4$optionshtml .= "<br />\r\n";
        } while(
    $rs2=mysql_fetch_assoc($result));
        
    $optionshtml .= '</td></tr>';
       }elseif(
    abs((int)$rs2['optType'])==4){
        if(@
    $multipurchasecolumns==''$multipurchasecolumns=2;
        
    $colwid=(int)(100/$multipurchasecolumns);
        if((int)
    $rs2['optGrpSelect']!=&& ! $isdetail){
         
    $hasmulti 2;
        }else{
         
    $index 0;
         do {
          if(
    $useStockManagement && $rs['pStockByOpts']!=&& $rs2['optStock'] <= 0$oostock=TRUE; else $oostock=FALSE;
          if((
    $index $multipurchasecolumns) == 0$optionshtml .= '<tr>';
          
    $optionshtml .= '<td width="'.$colwid.'%" align="left">&nbsp;&nbsp;<input type="text" name="optn'.$rs2['optID'].'" size="1" '.($oostock?'style="background-color:#EBEBE4" disabled':'').'/>';
          
    $optionshtml .= '<span class="multioption';
          if(
    $oostock$optionshtml .= ' oostock"'; else{ $optionshtml .= '"'$opthasstock=TRUE; }
          
    $optionshtml .= '> - ' $rs2[getlangid('optName',32)];
          if(@
    $hideoptpricediffs != TRUE && (double)$rs2['optPriceDiff'] != 0){
           
    $optionshtml .= ' (';
           if((double)
    $rs2['optPriceDiff'] > 0$optionshtml .= '+';
           if((
    $rs2['optFlags']&1)==1)$pricediff = ($rs['pPrice']*$rs2['optPriceDiff'])/100.0;else $pricediff $rs2['optPriceDiff'];
           if(@
    $showtaxinclusive===&& ($rs['pExemptions'] & 2)!=2$pricediff+=($pricediff*$thetax/100.0);
           
    $optionshtml .= FormatEuroCurrency($pricediff) . ')';
          }
          if(
    $index==0$optionshtml .= '<input type="hidden" name="ismulti" value="1" />';
          
    $optionshtml .= '</span></td>';
          
    $index++;
          if((
    $index $multipurchasecolumns) == 0$optionshtml .= '</tr>';
         } while(
    $rs2=mysql_fetch_assoc($result));
         if((
    $index $multipurchasecolumns) != 0){
          while((
    $index $multipurchasecolumns) != 0){
           if(
    $index>=$multipurchasecolumns$optionshtml .= '<td>&nbsp;</td>';
           
    $index++;
          }
          if((
    $index $multipurchasecolumns) == 0$optionshtml .= '</tr>';
         }
         
    $hasmulti 1;
        }
       }else{
        
    $optionshtml .= '<tr><td align="right" width="30%">' $grpnmstyle $rs2[getlangid('optGrpName',16)] . ':' $grpnmstyleend '</td><td align="left"> <select class="prodoption" onchange="' . (($rs['pPrice']==&& @$pricezeromessage != '') || @$noprice==TRUE ?'dummyfunc':'updateprice' $Count) . '();updateoptimage('.$Count.','.$rowcounter.','.($isdetail?'1':'0').');" name="optn' $rowcounter '" size="1">';
        
    $defimagejs .= 'updateoptimage('.$Count.','.$rowcounter.','.($isdetail?'1':'0').',2);';
        
    $gotdefaultdiff FALSE;
        
    $firstpricediff 0;
        if((int)
    $rs2['optGrpSelect']!=0)
         
    $optionshtml .= '<option value="">' $xxPlsSel '</option>';
        else
         if((
    $rs2['optFlags']&1)==1)$firstpricediff = ($rs['pPrice']*$rs2['optPriceDiff'])/100.0;else $firstpricediff $rs2['optPriceDiff'];
        do {
         
    $optionshtml .= '<option ';
         if(
    $useStockManagement && $rs['pStockByOpts']!=&& $rs2['optStock'] <= 0$optionshtml .= 'class="oostock" '; else $opthasstock=true;
         
    $optionshtml .= 'value="' $rs2['optID'] . '"'.((int)$rs2['optDefault']!=0?' selected':'').'>' $rs2[getlangid('optName',32)];
         if(@
    $hideoptpricediffs != TRUE){
          if((double)(
    $rs2['optPriceDiff']) != 0){
           
    $optionshtml .= ' (';
           if((double)(
    $rs2['optPriceDiff']) > 0$optionshtml .= '+';
           if((
    $rs2['optFlags']&1)==1)$pricediff = ($rs['pPrice']*$rs2['optPriceDiff'])/100.0;else $pricediff $rs2['optPriceDiff'];
           if(@
    $showtaxinclusive===&& ($rs['pExemptions'] & 2)!=2$pricediff+=($pricediff*$thetax/100.0);
           
    $optionshtml .= FormatEuroCurrency($pricediff) . ')';
           if(
    $rs2['optDefault']!=0)$optpricediff += $pricediff;
          }
          if(
    $rs2['optDefault']!=0)$gotdefaultdiff=TRUE;
         }
         if(
    $useStockManagement && @$showinstock==TRUE && @$noshowoptionsinstock != TRUE && (int)$rs["pStockByOpts"] != 0$optionshtml .= str_replace('%s'$rs2['optStock'], $xxOpSkTx);
         
    $optionshtml .= "</option>\n";
        } while(
    $rs2=mysql_fetch_assoc($result));
        if(@
    $hideoptpricediffs != TRUE && ! $gotdefaultdiff$optpricediff += $firstpricediff;
        
    $optionshtml .= '</select></td></tr>';
       }
      }
      
    $optionshavestock = ($optionshavestock && $opthasstock);
     }
     return(
    $optionshtml);
    }
    This is using arrays and loops for the different product option input types, right?
    Last edited by rlhanson; 01-18-2009 at 12:48 PM. Reason: wrong function posted!
    Thank you,
    Lynne Hanson
    RL Hanson-Online

  4. #94
    rlhanson's Avatar
    rlhanson is offline Master Glow Jedi
    Join Date
    Aug 2007
    Location
    Chapman, Kansas
    Posts
    531

    Default

    Nevermind ... just as lost with this idea!

    Before you go with this... I had a thought -
    the shopping cart dynamically displays the product images...maybe it would be better to make each background image a product since this is the way the code is already written...
    I'm about to peruse my db for a sec...

    What do you think about that idea?
    Last edited by rlhanson; 01-18-2009 at 01:07 PM.
    Thank you,
    Lynne Hanson
    RL Hanson-Online

  5. #95
    jmarcv's Avatar
    jmarcv is offline Cranky Coder
    Join Date
    Jan 2005
    Posts
    354

    Default

    Quote Originally Posted by rlhanson View Post
    I like this - I could use the same concept for the images too - still a long way from arrays and loops though.
    Ummm.... I gave yo a MUCH simpler way for your images...

    First, rename them
    3bamboo.jpg to 414.jpg
    9birchlake.jpg to 415.jpg

    Then just do this:
    Code:
    <?php 
      $optn2 = $_POST['optn2'];
    echo "<table width='325' height='200' border='0' align='center' cellpadding='0' cellspacing='0' background='designer/images/pics/backgrounds/{$optn2}.jpg'>";
    ?> 

  6. #96
    jmarcv's Avatar
    jmarcv is offline Cranky Coder
    Join Date
    Jan 2005
    Posts
    354

    Default

    Quote Originally Posted by rlhanson View Post
    This is using arrays and loops for the different product option input types, right?
    Yes, $prodoptions is the array

  7. #97
    jmarcv's Avatar
    jmarcv is offline Cranky Coder
    Join Date
    Jan 2005
    Posts
    354

    Default

    Quote Originally Posted by rlhanson View Post
    Nevermind ... just as lost with this idea!

    would be better to make each background image a product since this is the way the code is already written...
    Wouldnt it be better as I illustrated to just rename your images to match the DB?

  8. #98
    rlhanson's Avatar
    rlhanson is offline Master Glow Jedi
    Join Date
    Aug 2007
    Location
    Chapman, Kansas
    Posts
    531

    Default

    Yes it would and I actually get that now! lol It's been a long weekend - like trying to read chinese...

    Now, as I'm sure you guessed... I have another idea....

    How would I code this portion:
    PHP Code:
    if(is_array($prodoptions)){
      if(
    $noproductoptions==TRUE){
       
    $hasmultipurchase=2;
      }else{
       if(
    $prodoptions[0]['optType']==&& @$noproductoptions!=TRUE$thestyle=''; else $thestyle=' width="100%"';
       
    $optionshtml displayproductoptions('<strong><span class="prodoption">','</span></strong>',$optdiff,$thetax,FALSE,$hasmultipurchase);
       if(
    $optionshtml!='') print '<div class="prodoptions"><table border="0" cellspacing="1" cellpadding="1"'.$thestyle.'>' $optionshtml '</table></div>';
       
    $rs['pPrice'] += $optdiff;
      }
     
     }    
    ?> 
    ... to have it say if the optID is optn2 then have this "class" assigned? I know I can change the div class, but don't know how to tell it that only if optn2 is being displayed. Is that possible?

    My reasoning is this... I have figured out that the shopping cart allows for alt product images based on the product options - and the way I have it coded is to display product options which increase the price - I want to hide the background option in the incproductbody.php page.

    Going on to rename images!
    Thank you,
    Lynne Hanson
    RL Hanson-Online

  9. #99
    jmarcv's Avatar
    jmarcv is offline Cranky Coder
    Join Date
    Jan 2005
    Posts
    354

    Default

    Quote Originally Posted by rlhanson View Post
    ... to have it say if the optID is optn2 then have this "class" assigned? I know I can change the div class, but don't know how to tell it that only if optn2 is being displayed. Is that possible?
    Anything is possible.

    Well I dont see any optID, so I am not sure what you are asking.
    You mean if $optID='optn2';
    or do you mean if $optID=$_POST['optn2'];
    or something else?
    In the latter,
    #1
    Code:
    $optionshtml = displayproductoptions('<strong><span class="prodoption CUSTOM'.$_POST['optn2'].'">' ,'</span></strong>',$optdiff,$thetax,FALSE,$hasmultipurchase);
    This would 'ADD' a class to the div. If the value of optn2 was 415, then it would add the class CLASS415 to the div, with which you could override anything in prodoption or enhance it.

    If you only need one class for any value of optn2, you could do this:
    Code:
    $extraclass=($_POST['optn2']>0 ? 'optn2class' : '');
    $optionshtml = displayproductoptions('<strong><span class="prodoption '.$extraclass.''">' ,'</span></strong>',$optdiff,$thetax,FALSE,$hasmultipurchase);

  10. #100
    rlhanson's Avatar
    rlhanson is offline Master Glow Jedi
    Join Date
    Aug 2007
    Location
    Chapman, Kansas
    Posts
    531

    Default

    If you only need one class for any value of optn2
    Yes, this is what I am looking for.

    The class I want to assign is hiddenPic

    Code:
    $extraclass=($_POST['optn2']>0 ? 'optn2class' : '');
    Is this a switch like optn2class or ' '? Or is this where I should place 'hiddenPic'?

    Code:
    <span class="prodoption '.$extraclass.'">' ,'</span></strong>',$optdiff,$thetax,FALSE,$hasmultipurchase);
    Isn't this resulting in prodoptionoptn2class because of the .
    or am I not following this?

    I thought it was going to be something like:
    Code:
    If ($optionshtml==$_POST['optn2']) print '<div class="hiddenPic"><table border="0" cellspacing="1" cellpadding="1"'.$thestyle.'>' . $optionshtml . '</table></div>';
    but this doesn't work! LOL
    Thank you,
    Lynne Hanson
    RL Hanson-Online

Page 10 of 15 FirstFirst ... 67891011121314 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14