PHP q?

Out of context: Reply #7

  • Started
  • Last post
  • 7 Responses
  • welded0

    Well, again, there are a hundred and one ways to do this (I counted), but here if your $details variable will always match the $img variable then just set one with the other. By this I mean:

    $details = $img;

    Now they're both equal to the same thing. If they don't always match then you can either hard code it into the url like cosmo is suggesting or you could use a conditional like if-then-else or switch to set it.

    if ($img = 1) {
    $detail = 5;
    } else-if ($img = 2) {
    $detail = 10;
    }

    or

    switch ($img) {
    case 1;
    $details = 5;
    break;
    case 2;
    $details = 10;
    break;
    }

View thread