首页 > 解决方案 > 用于在 for 循环中获取数据的 while 循环无法正常工作

问题描述

我已将字符串拆分为 9 个元素,然后对于每个元素,我尝试使用 where 条件从表中获取数据。但是我得到了第一个拆分元素的值。假设我的第一个字符串元素是 Bislol 5 mg Tablet,使用它我得到代码 BS01。我的第二个拆分元素是 Clavusef 250 毫克片剂,为此我也得到了代码 BS01。我在下面给出我的代码。需要这方面的解决方案。

<?php

     $id = $_POST["MPO_CODE"];

     $categoryid="Bislol 5 mg Tablet, Bislol Max 2.5/5 mg Tablet, Clavusef".
     " 250 mg Tablet, Cosarin Tablet, Diohes 500 mg Tablet, Finix 20 mg ".
     "Tablet, Finix 20 mg Tablet, Hypen-SR 1.5 mg Tablet, Peptofit 200 ml ".
     "Suspension";

     $cat_ids = (explode(",", $categoryid));
     $count = count($cat_ids);

     $conn = oci_connect("");
     for ($i = 0; $i < $count; $i++)
     {                
         $catid = $cat_ids[$i];
         $p = oci_parse($conn2,"SELECT P_DESC   FROM 
                                 SAM_PRODUCT
                                 WHERE P_DESC= '$catid' " );
         oci_execute($p);
         while ($row = oci_fetch_array($p, OCI_ASSOC+OCI_RETURN_NULLS)) {
             $P_DESC= $row["P_DESC"];
         }

         echo $catid;
         echo "<br>";
         echo $P_DESC;

         echo "<br>";       
         echo "<br>";
         echo "<br>";
         echo "<br>";
     }

标签: phporaclefor-looporacle-call-interface

解决方案


推荐阅读