Page 1 of 1

Adding text to a string

Posted: Fri Sep 09, 2005 4:20 pm
by Cateyes
I am having troble adding text to a string I have done it before but am having trouble remebering how I did it here is the code that doesn't work.

Code: Select all

<?php
$optionst = "";
?>
   <?php 
	if ($row_rs_stock['leather'] == "Y") {
        $optionst = ($optionst + "Leather Interior, ");
		}
    if ($row_rs_stock['AC'] == "Y") {
        $optionst = ($optionst + "Air Conditioning, ");
         }
	if ($row_rs_stock['2dr'] == "Y") {
        $optionst = ($optionst + "2 Door, ");
         }
	if ($row_rs_stock['3dr'] == "Y") {
        $optionst = ($optionst + "3 Door, ");
        }
	if ($row_rs_stock['4dr'] == "Y") {
        $optionst = ($optionst + "4 Door, ");
        }
	if ($row_rs_stock['5dr'] == "Y") {
        $optionst = ($optionst + "5 Door, ");
        }
	if ($row_rs_stock['atuo_trans'] == "Y") {
        $optionst = ($optionst + "Automatic Transmission, ");
        }
	if ($row_rs_stock['stndrd_trans'] == "Y") {
        $optionst = ($optionst + "Standard Transmission, ");
        }
	if ($row_rs_stock['2WhDrive'] == "Y") {
        $optionst = ($optionst + "2 Wheel Drive, ");
        }
	if ($row_rs_stock['4WhDrive'] == "Y") {
        $optionst = ($optionst + "4 Wheel Drive, ");
        }
	if ($row_rs_stock['FWDrive'] == "Y") {
        $optionst = ($optionst + "Front Wheel Drive, ");
        }
	if ($row_rs_stock['AWDRive'] == "Y") {
        $optionst = ($optionst + "All Wheel Drive, ");
        }
	if ($row_rs_stock['ABS'] == "Y") {
        $optionst = ($optionst + "ABS, ");
        }
	if ($row_rs_stock['PowerBrakes'] == "Y") {
        $optionst = ($optionst + "Power Brakes, ");
        }
	if ($row_rs_stock['TiltSteering'] == "Y") {
        $optionst = ($optionst + "Tilt Steering, ");
        }
	if ($row_rs_stock['PowerSteering'] == "Y") {
        $optionst = ($optionst + "Power Steering, ");
        }
	if ($row_rs_stock['PowerLocks'] == "Y") {
        $optionst = ($optionst + "Power Locks, ");
        }
	if ($row_rs_stock['PowerMirrors'] == "Y") {
        $optionst = ($optionst + "Power Mirrors, ");
        }
	if ($row_rs_stock['PowerSeats'] == "Y") {
        $optionst = ($optionst + "Power Seats, ");
        }
	if ($row_rs_stock['PowerWindows'] == "Y") {
        $optionst = ($optionst + "Power Windows, ");
        }
	if ($row_rs_stock['SunRoof'] == "Y") {
        $optionst = ($optionst + "Sun Roof, ");
        }
	if ($row_rs_stock['AM'] == "Y") {
        $optionst = ($optionst + "AM Radio, ");
        }
	if ($row_rs_stock['AM_FM'] == "Y") {
        $optionst = ($optionst + "AM/FM Radio, ");
        }
	if ($row_rs_stock['Cassette'] == "Y") {
        $optionst = ($optionst + "Cassette, ");
        }
	if ($row_rs_stock['CD'] == "Y") {
        $optionst = ($optionst + "CD Player, ");
        }
	if ($row_rs_stock['DVD'] == "Y") {
        $optionst = ($optionst + "DVD Player, ");
        } ?>
This is probably so simple I think I will lay down get some sleep and see if the answer comes to me.
Thanks for any help I get.

Posted: Fri Sep 09, 2005 4:22 pm
by feyd
swap + for . ;)

You're using a math operator, you want to use the string concatenation operator

string operators

Posted: Fri Sep 09, 2005 4:24 pm
by Cateyes
Thats why I was getting a number as a result I am so tired thanks :lol: