duaijiao0648 2015-09-09 03:18
浏览 36
已采纳

PHP编程错误(无法运行while循环)

<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />

<?php
    session_start();

    $conn = mysqli_connect("localhost", "root", "","test");

    $product_code = $_GET['product_code'];
    $sql = "SELECT * FROM test_config WHERE product_code = '$product_code'";
    $product_list = mysqli_query ( $conn, $sql);

    if($product_list = 1)
    echo"good";
    else
    echo"bad"; 
?>
</head>

<body>

<span id="tttt"></span>
<form id="msform" method="post">
<!-- progressbar -->
<ul id="progressbar">
<li class="active">

<?php While ($one_product = mysqli_fetch_assoc($product_list)) {?>


<li><?php echo $one_product['test_name']; ?></li>

<?php } ?>

<!-- <a href="index.html" >Start-Over</a>  -->
<span onclick="window.close()" style="float:right">Start-Over</span>
</ul>

<?php While ( $one_product = mysqli_fetch_assoc($product_list)  ) { 

        $num_test = $one_product['num_test'];
        $test_name = $one_product['test_name'];
        $images_pos = $one_product['images_pos'];
        $images_neg = $one_product['images_neg'];
        $images_inv = $one_product['images_inv'];
?>
<!-- fieldsets -->
<fieldset id="<?php $test_name; ?>" data-set="0">
<h2 class="fs-title"><?php echo "$test_name"; ?></h2>
<img src="images/<?php $images_pos; ?>"  class="case" data-case="1"/><br/>
<input name="<?php $test_name; ?>" type="radio" value="N" class="hide">
<img src="images/<?php $images_neg; ?>"  class="case" data-case="2"/><br/>
<input name="<?php $test_name; ?>" type="radio" value="P" class="hide">
<img src="images/<?php $images_inv; ?>"  class="case" data-case="3"/><br/>
<input name="<?php $test_name; ?>" type="radio" value="I" class="hide">
<img src="images/skip_button.fw.png"  class="case" data-case="4"/><br/>
<input name="<?php $test_name; ?>" type="radio" value="S" class="hide">
<br/>

<?php if ($num_test > 1) { ?>
<input type="button" name="next" class="next action-button" value="Next" />

<br/>
<?php if($num_test == 1) { ?>

<input type="button" name="previous" class="previous action-button" value="Previous" />
<input type="button" name="submit" id="submit" class="action-button" value="SAVE" />

</fieldset>
<?php }
$num_test --; ?>
<?php } }?>

</form>

</body>
</html>

Errors: Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, integer given on line 41 and line 52 (Line that contain )

Please help me thanks!!!!! The sql does get the data from the database. However, the while loop is still having some errors.

  • 写回答

3条回答 默认 最新

  • doute3621 2015-09-09 06:51
    关注

    if($product_list = 1) echo"good"; else echo"bad";

    Shouldnt be there. As it will make $product_list into boolean and thus cannot run through the loop

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码