SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2010
    Location
    Rochester, NY
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to concatenate 3 variables in one table cell

    I'm very new to php, but I'm trying to modify a shopping cart and put 3 variables in one table cell instead of the 2 that were there originally. The original code was:

    $content .= '<tr id="'.$item.'"><td>'.$crtName[$item].$sp_comments.'</td><td style="text-align:left;">'.$crtOptions[$item].'</td><td style="text-align:center;"><input class="quantity" name="'.$item.'" type="text" value="'.$crtQuantity[$item].'" /></td><td style="text-align:center;"><a href="'.$GLOBALS["CARTURL"].'?remove='.$item.'" class="crtRemove">'.mkt_SHOPCART_ITEM_REMOVE.'</a></td><td style="text-align:right;">'.$mkt_pk_item_amount.'</td></tr>';

    The part I'm trying to change is:

    <td>'.$crtName[$item].$sp_comments.'</td>

    This code works fine and displays both variables in one cell. I want to add a 3rd variable to the cell, so I did this:

    <td>'.$crtName[$item].$sp_comments.$sp_comments2.'</td>

    The cell now displays $crtName[$item] and $sp_comments2 but not $sp_comments. Am I doing something wrong?

  2. #2
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Your code is fine, it means the variable is empty.


Bookmarks

Posting Permissions

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