duanli9569 2015-03-26 18:13 采纳率: 100%
浏览 95

在while循环中使用会话来限制输出

I have this script to limit the output of a MySQL database so that when a string is detected to be more than 140 characters long the script treats it as 2 lines instead of one.

while($row = mysqli_fetch_array($result)) {
    $stringl = "$input";
    if ((strlen($stringl) > 140) && (!$_SESSION["" . $row['ID'] . ""]) && (!empty("".$_SESSION["text-lines"].""))) {
        $_SESSION["" . $row['ID'] . ""] = "" . $row['ID'] . "";
        $_SESSION["text-lines"] = $_SESSION["text-lines"] - 1;
    }

I am storing the unique ID of the string in a session to avoid this code being ran again when the page is refreshed but it doesn't work:

Presently if one string contains more than 140 characters, 1 is deducted from the text-lines session every time the script is refreshed.

The expected result is for 1 to be deducted once from text-lines session and then that same line wouldn't be able to deduct another line from text-lines.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度