Adding text to a string

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

Adding text to a string

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

swap + for . ;)

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

string operators
Cateyes
Forum Commoner
Posts: 63
Joined: Mon Jun 14, 2004 5:06 pm

Post by Cateyes »

Thats why I was getting a number as a result I am so tired thanks :lol:
Post Reply