在我的php代码中,我尝试从数据库中获取多个文本字符,并在每个结果输出中str_split
。将USED
添加到每个输出的结束行,并输出剩余的字符,我也尝试过:
require("init.php");
echo "<form action='reg.php' method='post'>
<b>booking code:</b><br />
<input type='text' name='book' size='17' />
<input type='submit' name='login' maxlength='2' size='2' value='PRINT OUT' />
</form>";
if(isset($_POST["login"]))
{
$book = mysqli_real_escape_string($conn, $_POST["book"]);
$sql = "SELECT `item_name` , `quantity` FROM `books` WHERE `book`='$book'"; $query = mysqli_query($conn, $sql);
while ($row1 = mysqli_fetch_array($query)) {
$d[] = $row1["item_name"];
$v[] = $row1["quantity"];
foreach($d as $r);
foreach($v as $ro);
$get = array(0 => array("yes" => $r, "no" => $ro));
foreach ($get as $item) {
$getd = $item["yes"];
}
$sql = mysqli_query($conn, "SELECT * FROM promo WHERE code='$getd' LIMIT 1");
while ($row = mysqli_fetch_array($sql)) {
$type = $row["name"];
$code = $row["recharge"];
$deta = $row["details"];
$logo = $row["logo"];
$price = $row["price"];
if(preg_match('/(xyz)/i', $type)) $type = "20";
if(preg_match('/(log)/i', $type)) $type = "16";
}
$id = $item["no"];
$result = str_split($code, $type);
$a = "";
$c = "";
for($b = 0; $b<$id; $b++)
{
$a .= $result[$b];
}
$b = "USED";
for($bn = $id; $bn<sizeof($result); $bn++){
$c .= $result[$bn];
}
echo $a.$b.$c;
}
}
}
并且我的所有结果输出代码都是不可知的,我说所有结果都是完整的结果输出,感谢您在我的解决方案中的时间和影响