Jump to content

Seancon1

New Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by Seancon1

  1. I am unable to echo content in my mysql_fetch_array..

    $query_sum = mysql_query("SELECT ip, cases, motherboards, cpu, video_cards, ram,
    power_supply, sound_cards, storage, media_player, cpu_cooling, monitor, accessories FROM sessions WHERE ip = '$ip'") or die(mysql_error());
    while($get = mysql_fetch_array( $query_sum )) {
    
    $item1 = $get['cases'];
    $item2 = $get['motherboards'];
    $item3 = $get['cpu'];
    $item4 = $get['video_cards'];
    $item5 = $get['ram'];
    $item6 = $get['power_supply'];
    $item7 = $get['sound_cards'];
    $item8 = $get['storage'];
    $item9 = $get['media_player'];
    $item10 = $get['cpu_cooling'];
    $item11 = $get['monitor'];
    $item12 = $get['accessories'];
    
    $items = array("1" => "$item1", "2" => "$item2", "3" => "$item3", "4" => "$item4", "5" => "$item5",
    "6" => "$item6", "7" => "$item7", "8" => "$item8", "9" => "$item9", "10" => "$item10", "11" => "$item11",
    "12" => "$item12");
    
    echo "Displaying: " . $item3;
    
    }
    
    

     

     

    echo "Displaying: " . $item3;

     

     

    Does not return anything, not even the "Displaying" text is displayed. I remember being able to echo like this in the past, why not now?

  2. Solved

    I found the solution, thank you for looking at my post anyways.

     

    <?php
    
    $items = array ( "1" => $item1, "2" => $item2, "3" => $item3 );
    $items1 = $items['1'];
    echo "The item has been displayed \$items1 = $items1 <br />";
    $k = 1;
    while($k < 4) {
    $prod_item_num = $items["$k"];
    $unique_query1 = "SELECT * FROM product_db WHERE id = $prod_item_num";
    echo $unique_query1;
    echo "<br />";
    $k++;
    }
    
    ?>

     

    Displays:

    The item has been displayed $items1 = one
    SELECT * FROM product_db WHERE id = one
    SELECT * FROM product_db WHERE id = two
    SELECT * FROM product_db WHERE id = three
    

     

     

  3. <?php
    
    $item1 = "one";
    $item2 = "two";
    $item3 = "three";
    $k = 1;
    while($k < 4) {
    $prod_item_num = "\$item" . $k;
    $unique_query1 = "SELECT * FROM product_db WHERE id = $prod_item_num";
    echo $unique_query1;
    echo "<br />";
    $k++;
    }
    
    ?>
    

     

    The above displays the following

     

    SELECT * FROM product_db WHERE id = $item1
    SELECT * FROM product_db WHERE id = $item2
    SELECT * FROM product_db WHERE id = $item3
    

     

    I need the $item(1-3) values to echo what I made them. I've tried many different ways, none of which worked.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.