Anyway, i'm working on a PHP module for a CMS where if in the database a website user is either selected as, "GBP" or "EUR" in their Countries' currency field, a set of text is displayed. And if the users' currency is either, "USD" or "JPY", a different set of text is displayed.

I've got a query, selecting the currency column against the users' ID no. Made a variable of that and have two if statements running the text as below:


// query
mysql_select_db($database, $dbconnect);
$query_getusercurrency = "SELECT my_currency FROM ".$sitename."_users WHERE id = '$wsuserid'";
$getusercurrency = mysql_query($query_getusercurrency, $dbconnect) or die(mysql_error($dbconnect));
$row_getusercurrency = mysql_fetch_assoc($getusercurrency);
$totalRows_getusercurrency = mysql_num_rows($getusercurrency);

$variable = $row_getusercurrency;

if ($variable == "GBP" || "EUR"){
$display = "my text here";

if ($variable == "USD" || "JPY") {
$display = "my text here";

<p><?php echo $display; ?></p>

when it's processed on the web it only displays the first option no matter what the users currency has been set to, I tried an "if.. else" statement but then that activates the second option no matter the user.

So can anyone help me out on where i'm going wrong?

9 Years
Discussion Span
Last Post by JSR

I'm no PHP expert but do you have to have a complete comparison for each item in the expression?


if ( ($variable == "GBP") || ($variable ==  "EUR") ){
$display = "my text here";

Thanks pty, that's cleared the problem up entirely, i think i've learned that same stuff can't be shortcutted

Thanks again.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.