jeudi 10 septembre 2015

PHP. Loop through database results

    <?php 
session_start(); 
require_once("Connection/cid.php"); 
$conn = mysqli_connect("localhost", "root", "","cid"); 
$product_code = $_GET['product_code']; 
$sql = "SELECT * FROM test_config WHERE product_code = '$product_code'"; $product_list = mysqli_query( $conn, $sql); 
?>   

 -------------------------------------------------------------

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

    <?php $num = 0; while ($one_product = mysqli_fetch_assoc($product_list)) 
    {
        $num_test = $one_product['num_test'];
    ?>

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

    <?php 
    $num ++;
    if($num == $num_test)
    break;
    } ?>

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

My problem is the loop never end so i added a break at the end of the loop but the codes doesnt seems to be continue running. Can you help me solve my problem? Thank you.

Database side have no problem. Results are showing out, it is only for the loop there is problem.

Aucun commentaire:

Enregistrer un commentaire