2016-06-30 5 views
0

This is the modal of a specific customer information i'm trying to makeループは、私は私のモーダルですべての結果を示す問題を抱えているクエリ

からすべての結果を表示していないが。モーダルに表示する行は3行あります:2016年6月、2016年5月、2016年4月の請求月ですが、最新のもの(2016年6月)のみが表示されます。ここに私のコードの一部です:

if(isset($_GET['id'])) 
         { 

          $page_id = $_GET['id']; 

          $select_query = "SELECT * FROM billing_info INNER JOIN customer_login ON billing_info.account_no=customer_login.account_no WHERE billing_info.account_no='$page_id' "; 

          $run_query = mysqli_query($conn,$select_query); 

          while($row = mysqli_fetch_array($run_query)) 
          { 
           $id = $row['user_id']; 
           $cust_fname = $row['cust_fname']; 
           $cust_mname = $row['cust_mname']; 
           $cust_lname = $row['cust_lname']; 
           $branch = $row['branch']; 
           $account_no = $row['account_no']; 
           $billing_month = $row['billing_month']; 
           $pres_reading = $row['pres_reading']; 
           $prev_reading = $row['prev_reading']; 
           $payment_status = $row['payment_status']; 
           $due_date = $row['due_date']; 
           $int_pres = intval($row["pres_reading"]); 
           $int_prev = intval($row["prev_reading"]); 
           $difference = $int_pres-$int_prev; 
           $payment = $difference*26.678; 

           $cust_fname = ucfirst($cust_fname); 
           $cust_mname = ucfirst($cust_mname); 
           $cust_lname = ucfirst($cust_lname); 
           $branch = ucfirst($branch); 

        ?> 

    <div id="openModal" class="modalDialog" style="width:100%;"> 
    <div id="form-sms" style="height: 500px; overflow: scroll;"> 
    <div class="close"><a href="admin-customers.php"> X</a></div> 

    <form method="get" action="customer_view.php?id=<?php echo $id; ?>" name="id" enctype="multipart/form-data"> 

<table width="100%" bgcolor="white" align="center"> 
    <style type="text/css"> 


    td.hundred{ 
     width: 80%; 
     text-align: center; 
    } 
    input { 
     width: 100%; 
    } 
    input[type="text"]{ 
     width: 90%; 
     text-align: left; 
    } 
    input[type="submit"]{ 
     width: 100%; 
     text-align: center; 
    } 
    textarea{ 
     width: 90%; 
     text-align: left; 
     margin-left: 10%; 
    } 
    td { 
     padding: 10px; 
    } 
    .tdhover:hover { 

     color: #AFEEEE; 
    } 
    </style> 


       <tr > 
        <td align="center" colspan="10"><h1><?php echo $cust_fname." ".$cust_mname." ".$cust_lname." - ".$account_no." - ".$branch." Details" ?></h1></td> 
       </tr> 

       <tr bgcolor="#20B2AA"> 

        <th>Billing Month</th> 
        <th>Present Reading</th> 
        <th>Previous Reading</th> 
        <th>Payment</th> 
        <th>Status</th> 
        <th>Due Date</th> 
        <th>Water Usage (in m<sup>3</sup>)</th> 
        <th>Edit</th> 
       </tr> 
       <tr bgcolor="#AFEEEE"> 


        <td><?php echo $billing_month; ?></td> 
        <td><?php echo $pres_reading; ?></td> 
        <td><?php echo $prev_reading; ?></td> 
        <td><?php echo "Php " . $payment; ?></td> 
        <td><?php echo $payment_status; ?></td> 
        <td><?php echo $due_date; ?></td> 
        <td><?php echo $difference; ?></td> 


        <td><a href="billing_edit_posts.php?edit=<?php echo $id; ?>">Edit</a></td> 
       </tr> 

       <tr style="margin-top: 10px;"> 
        <td bgcolor="#20B2AA" align="center" class="tdhover" colspan="10"><a href="billing_add.php" style="text-decoration:none; color: white; ">Add Billing Information</a></td> 
       </tr> 



</table> 
</form> 
</style> 
</table> 
</form> 
</div> 
</div> 


       <?php } }?> 
+0

データベース方式は何ですか? – Kray

+0

dbに対して直接クエリを実行して、期待される結果を得ることを確認できます –

+0

whileループを終了していません。 –

答えて

0

あなたがループ/のみ<tr><td>のためではない<table>と外側<div>テーブルのようにすべてのタグのデータを解析する必要があります。 Htmlは内部のすべてをループします{ ... }符号。 それから、あなたのスタイル・コードを上に置くべきです(html/phpで修正しないでください)。このコードは次のようになります。

 <style type="text/css"> 
td.hundred{ 
    width: 80%; 
    text-align: center; 
} 
input { 
    width: 100%; 
} 
input[type="text"]{ 
    width: 90%; 
    text-align: left; 
} 
input[type="submit"]{ 
    width: 100%; 
    text-align: center; 
} 
textarea{ 
    width: 90%; 
    text-align: left; 
    margin-left: 10%; 
} 
td { 
    padding: 10px; 
} 
.tdhover:hover { 

    color: #AFEEEE; 
} 
</style> 
<?php 

if (isset($_GET['id'])) {//open the isset 
    $page_id = $_GET['id']; 
$select_query = "SELECT * FROM billing_info INNER JOIN customer_login ON billing_info.account_no=customer_login.account_no WHERE billing_info.account_no='$page_id' "; 

$run_query = mysqli_query($conn, $select_query); 
?> 


<div id="openModal" class="modalDialog" style="width:100%;"> 
    <div id="form-sms" style="height: 500px; overflow: scroll;"> 
     <div class="close"><a href="admin-customers.php"> X</a></div> 

     <form method="get" action="customer_view.php?id=<?php echo $id; ?>" name="id" enctype="multipart/form-data"> 

      <table width="100%" bgcolor="white" align="center"> 
<?php 
while ($row = mysqli_fetch_array($run_query)) { //open the while 
    $id = $row['user_id']; 
    $cust_fname = $row['cust_fname']; 
    $cust_mname = $row['cust_mname']; 
    $cust_lname = $row['cust_lname']; 
    $branch = $row['branch']; 
    $account_no = $row['account_no']; 
    $billing_month = $row['billing_month']; 
    $pres_reading = $row['pres_reading']; 
    $prev_reading = $row['prev_reading']; 
    $payment_status = $row['payment_status']; 
    $due_date = $row['due_date']; 
    $int_pres = intval($row["pres_reading"]); 
    $int_prev = intval($row["prev_reading"]); 
    $difference = $int_pres - $int_prev; 
    $payment = $difference * 26.678; 

    $cust_fname = ucfirst($cust_fname); 
    $cust_mname = ucfirst($cust_mname); 
    $cust_lname = ucfirst($cust_lname); 
    $branch = ucfirst($branch); 
    ?> 


        <tr > 
         <td align="center" colspan="10"><h1><?php echo $cust_fname . " " . $cust_mname . " " . $cust_lname . " - " . $account_no . " - " . $branch . " Details" ?></h1></td> 
        </tr> 

        <tr bgcolor="#20B2AA"> 

         <th>Billing Month</th> 
         <th>Present Reading</th> 
         <th>Previous Reading</th> 
         <th>Payment</th> 
         <th>Status</th> 
         <th>Due Date</th> 
         <th>Water Usage (in m<sup>3</sup>)</th> 
         <th>Edit</th> 
        </tr> 
        <tr bgcolor="#AFEEEE"> 


         <td><?php echo $billing_month; ?></td> 
         <td><?php echo $pres_reading; ?></td> 
         <td><?php echo $prev_reading; ?></td> 
         <td><?php echo "Php " . $payment; ?></td> 
         <td><?php echo $payment_status; ?></td> 
         <td><?php echo $due_date; ?></td> 
         <td><?php echo $difference; ?></td> 


         <td><a href="billing_edit_posts.php?edit=<?php echo $id; ?>">Edit</a></td> 
        </tr> 

        <tr style="margin-top: 10px;"> 
         <td bgcolor="#20B2AA" align="center" class="tdhover" colspan="10"><a href="billing_add.php" style="text-decoration:none; color: white; ">Add Billing Information</a></td> 
        </tr> 
<?php } //while closing 
?> 


      </table> 
     </form> 
     </style> 
     </table> 
     </form> 
    </div> 
</div> 

うまくいけば、それはあなたのための成功となります。)

+0

ありがとう!それはループしましたが、このエラーを示しました:通知:未定義の変数:idはC:\ wamp \ www \ WaterDistrict_2 \ admin \ customer_view.phpの81行で呼び出しスタック#TimeMemoryFunctionLocation 10.0020146664 {main}().. \ customer_view.php: – IlanaWexler

+0

エラーが参照しているコードは次のとおりです。 – IlanaWexler

+0

"name =" id "enctype =" multipart/form-data "> – IlanaWexler

関連する問題