gpt4 book ai didi

php - 如何使用 PHP 和 PDO 获取整数和文本以自动换行

转载 作者:行者123 更新时间:2023-11-29 02:59:07 25 4
gpt4 key购买 nike

当用户扫描条形码并将数字输入文本字段时,数字会一直向屏幕右侧移动。我需要它们来包装是否有更好的方法来编写此表来做到这一点?当用户扫描数字并按下空格键时,它们不会出现任何问题。

<?php
require_once("../db_connect.php");

$stmt = $db->prepare ("SELECT * FROM requests WHERE status='Received'");
echo"Received Requests";
echo "<br><br>";
$stmt->execute();
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
echo("<table bgcolor=F2F2F2 width=1080 border='2'>");

echo("<br><tr><th>Id</th><th>Update</th><th>LanID</th><th>Name</th><th>Location</th><th>Manager</th><th>request</th><th>Description</th><th>request_comments</th><th>Status</th><th>Comments</th><th>Completed User</th><th>Completed Date</th></tr>");

echo("<tr>");
echo "<td>". $row['id'] . "</td>"
."<td><a href='../update.php?id=" . $row['id'] . "'>Update</a></td>"
."<td>" . $row['lanId'] . "</td> "
. "<td>". $row['name'] . "</td>"
. "<td>". $row['department'] . "</td>"
. "<td>" . $row['manager'] . "</td>"
. "<td>" . $row['request'] ."</td>"
. "<td>" . $row['request_description'] ."</td>"
. "<td>" . $row['request_comments'] ."</td>"
. "<td>" . $row['status'] ."</td>"
. "<td>" . $row['comments'] ."</td>"
. "<td>" . $row['compUser'] ."</td>"
. "<td>" . $row['compDt'] ."</td>";
echo '</tr>';
echo("</table>");
}


?>

<html>
<head>
<meta http-equiv="refresh" content="5" >
<title></title>
</head>
<body background="../images/background.jpg">
</body>
</html>

我也以这种方式重写了代码。我还拆分了表格,以便它们都适合。

<!DOCTYPE> 
<html>

<head>

<title>Received Requests</title>
</head>
<body>
<?php
//conects to the database
require_once("../db_connect.php");

//prepared statement with PDO to query the database
$stmt = $db->prepare("SELECT * FROM requests WHERE status='Received'");
$stmt->execute();

echo"Received Requests";
?>

<?php //start of the while loop ?>
<?php while( $row = $stmt->fetch(PDO::FETCH_ASSOC) ) { ?>

<br>
<tr>
<th style="width:25px">ID</th>
<th style="width:65px">Date Requested</th>
<th style="width:40px">LanId</th>
<th style="width:140px ">Name</th>
<th style="width:125px">Dept.</th>
<th style="width:140px">Manager</th>
<th style="width:100px">Request</th>

</tr>
<tr style="width:25px">
<?php $id = $row['id'];?>
<?php echo "<td> <a href='../update.php?id=$id'>$id</a></td>"?>
<td style="width:65px"><?php echo $row['date_requested']; ?></td>
<td style="width:40px"><?php echo $row['lanId']; ?></td>
<td style="width:140px"><?php echo $row['name']; ?></td>
<td style="width:125px"><?php echo $row['department']; ?></td>
<td style="width:140px"><?php echo $row['manager']; ?></td>
<td style="width:100px"><?php echo $row['request']; ?></td>

</tr>

</table>
<table border="1" style="table-layout: fixed; width: 1080px;">

<tr>
<th style="width:130px">Request Desc.</th>
<th style="width:140px">Request comments</th>
<th style="width:80px">Status</th>
<th style="width:160px">Comments</th>
<th style="width:40px">Comp. User</th>
<th style="width:65px">Comp. Date</th>
</tr>
<tr style="width:25px">

<td style="width:130px; word-break: break-all;"><?php echo $row['request_description']; ?></td>
<td><textarea name="request_comments" style="width: 235px; height: 81px" style="text-transform:uppercase ;"><?php echo $row['request_comments']; ?></textarea></td>
<td style="width:80px"><?php echo $row['status']; ?></td>
<td><textarea name="request_comments" style="width: 270px; height: 81px" style="text-transform:uppercase ;"><?php echo $row['comments']; ?></textarea></td>
<td style="width:40px"><?php echo $row['compUser']; ?></td>
<td style="width:65px"><?php echo $row['compDt']; ?></td>
</tr>


</table>
<?php } //end of the while loop?>
</body>

最佳答案

这是为了帮助其他有同样问题的人。因为这个网站上的大多数换行问题都没有涵盖数字不换行的事实。无论您尝试固定宽度的表格还是 td 上的 wrapword 都不起作用。您必须在 td 中放置一个文本框才能让数字换行。

这是我用于所有需要换行数字的行。

<td><textarea name="request_comments"  style="width: 235px; height: 81px" style="text-transform:uppercase ;"><?php echo $row['request_comments']; ?></textarea></td>

关于php - 如何使用 PHP 和 PDO 获取整数和文本以自动换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26661085/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com