Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Get ID from link

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #35898
    SycoLV
    Member

    Hey guys I have a little problem.
    I need to know why this links http://trailer.whitedigital.eu/single_axle?id=1 doesn’t understan that it has id=1 but this http://trailer.whitedigital.eu/blocks/single_axle.php?id=1 does.

    index.php code:


    switch($_GET) {
    case 'single_axle':
    $load_content = $prefix.'blocks/single_axle.php';
    break;
    }
    ?>
    ........




    single_axle.php code:


    $id = ($_GET);
    if (!isset($_GET)) {
    die("No ID in link");
    }


    if ($con) {
    $re = mysql_query("SELECT * FROM single_axle WHERE ID=$id ");
    if (mysql_num_rows($re) == 0) {
    echo "There is no DB entry with this ID";
    }
    else {
    while($row = mysql_fetch_array($re)) {
    $model = $row[1];
    $dime = $row[2];
    $gweight = $row[3];
    $uweight = $row[4];
    $payload = $row[5];
    $axletype = $row[6];
    $brakes = $row[7];
    $pricepvn = $row[8];
    $price = $row[9];
    $info = $row[10];
    $imgCount = $row[11];
    }
    echo "YEES! ALL WORKS";
    }
    }

    #93707
    angelazou
    Participant

    In both cases, you are looking for the content of the ID variable held in the GET superglobal variable. This means your code in index.php should look like this instead:


    switch($_GET) {
    case '1':
    $load_content = $prefix.'blocks/single_axle.php';
    break;
    }
    ?>

    And you can optionally not use that single quote there because numbers don’t need to be quoted.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.