Jump to content

Help!


artistan

Recommended Posts

I'm trying to run another sql query withing a while loop fetching rows of another query.
But for some reason I'm only expecting 2 rows, but the while loop goes into a infinite loop when I insert the 2nd query.

[code]    $item_result = $sys_database->sql_query(
    "SELECT `product`.`name`, `product`.`description`, "
    ."`product`.`height`, `product`.`length`, `product`.`width`, `product`.`weight`, "
    ."`product`.`base_price`, `product`.`price_unit`, "
    ."`item`.`iid`, `item`.`product_no`, `item`.`count`, `item`.`retail_price`, `item`.`status` FROM "
    ."`".$sys_config["dbpref"]."mod_inventory_product` AS `product`, "
    ."`".$sys_config["dbpref"]."mod_inventory_item` AS `item` "
    ."WHERE `product`.`pid` = `item`.`pid` AND `product`.`cid` = '$gp_mc_cid'");
    $item_count = $sys_database->sql_numrows($item_result);
    if($item_count) {
    $item_color = 0;
      while($item_item = $sys_database->sql_fetchrow($result)) {

      /* Any Query I insert here SELECT, INSERT, SHOW PROCESSLIST will cause the while loop to not end.
          Otherwise, it works just fine. */
      $sys_database->sql_query("SHOW PROCESSLIST");


        if($item_color == 1) {
        $item_color = 0;
        $id = " id=\"dark\"";
        } else {
        $item_color = 1;
        $id = "";
        }
        echo "    <div class=\"item\"".$id.">\n"
            ."    <div class=\"selection\"><input type=\"checkbox\" name=\"iid[]\" value=\"".$item_item["iid"]."\" /></div>\n"   
            ."    <div class=\"pid\">".$item_item["iid"]."</div>\n"
            ."    <div class=\"status\">\n";
        echo "    </div>\n"
            ."    <div class=\"quantity\">\n"
            ."    ".$item_item["count"]
            ."    </div>\n"
            ."    <div class=\"price\">\n"
            .$sys_config["unit_currency"].$item_item["retail_price"];

        if($sys_user->p_allinfo) echo "/".$sys_config["unit_currency"].$item_item["base_price"]."";
        echo "    </div>\n"
            ."    <div class=\"name\">\n"
            ."      <strong>".$item_item["name"]."</strong> [".$item_item["product_no"]."]<br />\n";
        $length = 50;
        $trailing = "...";
        $length-= strlen($trailing);
        if (strlen(stripslashes($item_item["description"])) > $length) {
        $item_description = substr(stripslashes($item_item["description"]),0,$length).$trailing;
        } else {
        $item_description = stripslashes($item_item["description"]);
        }
        echo "      $item_description<br />\n"
            .$item_item["length"]." ".$sys_config["unit_length"]." x "
            .$item_item["width"]." ".$sys_config["unit_length"]." x "
            ."      ".$item_item["height"]." ".$sys_config["unit_length"]
            ."    </div>\n"
            ."    </div>\n";
      }
    }
[/code]



Here's a log from the mysqld:

[code]  56 Query      SELECT * FROM `mod_inventory_category` WHERE `rid` = '0'  ORDER BY `name`
                56 Query      SELECT `product`.`name`, `product`.`description`, `product`.`height`, `product`.`length`, `product`.`width`, `product`.`weight`, `product`.`base_price`, `product`.`price_unit`, `item`.`iid`, `item`.`product_no`, `item`.`count`, `item`.`retail_price`, `item`.`status` FROM `mod_inventory_product` AS `product`, `mod_inventory_item` AS `item` WHERE `product`.`pid` = `item`.`pid` AND `product`.`cid` = '0'
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                56 Query      SHOW PROCESSLIST
                // Goes on and on...
[/code]
I have no clue why it's doing this...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.