php - 用于在 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>";
}
解决方案
推荐阅读
- c# - 不包含“ReturnsAsync”的定义和最佳扩展方法重载
- php - 防止用户在登录后返回登录表单?
- javascript - 异步 TS/JS 函数中的全局赋值是否安全,不会意外覆盖现有值?
- virtual-machine - 如果我的 VirtualBox 克隆永远不会同时运行,我是否需要一个新的 MAC 地址?
- java - 编写基于 SonarQube Java 的规则来检查 assertj 错误,无法确定何时不调用链式方法
- oracle - Oracle CLOB 数据类型给出错误:`SQL 错误:ORA-01704:字符串文字太长`
- python - 感知器没有正确学习
- javascript - 使用 addEventListener 时如何更新 id?
- python - 使用moviepy使用ffmpeg阅读视频
- amazon-web-services - AWS Fargate 延迟