Creating a variable in PHP -


hi trying create string, stored variable, value determined values in url. but, unsure how go it. keep getting error "unexpected t_if". doing wrong?

thanks

php:

        $where=                if (isset($_get['name'])) {                 echo "name=" . $name;             }             if (isset($_get['number'])) {                 echo " , number=" . $number;             }             if (isset($_get['address'])) {                 echo " , address=" . $address;             }             if (isset($_get['city'])) {                 echo " , city=" . $city;             }             if (isset($_get['state'])) {                 echo " , state=" . $state;             }             if (isset($_get['zip'])) {                 echo " , zip=" . $zip;             }             if (isset($_get['color'])) {                 echo " , color=" . $color;             }         ; 

you cannot declare php variable this. have concat variable.

<?php $where = ''; if (isset($_get['name'])) {     $where .= " name=" . $name; } if (isset($_get['number'])) {     $where .= " , number=" . $number; } if (isset($_get['address'])) {     $where .= " , address=" . $address; } if (isset($_get['city'])) {     $where .= " , city=" . $city; } if (isset($_get['state'])) {     $where .= " , state=" . $state; } if (isset($_get['zip'])) {     $where .= " , zip=" . $zip; } if (isset($_get['color'])) {     $where .= " , color=" . $color; } echo $where; ?> 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -