Search the Community
Showing results for tags 'dynamic table'.
-
Hi, I am trying to create dynamic tables that have the same structure and the content changes according to the info in a database. I have a loop that repeat the HTML table code and the PHP DB reading function. I am using the foreach loop syntax to break from the HTML code and tested on my local drive it works but on the server it does not show any table. Can you help me check of the syntax is correct on Heliohost? I also tested the same code in another server and it worked fine. Not sure where the problem is. Below the code: ------------------------------------------------------------------------------------------------------ <?phpinclude_once 'database/Database.php'; //this handles the Database session_start();$_SESSION['DEBUGGING'] = 'OFF'; // Init the DB.$db = new Database;$db->connect(); $sql = "SELECT stock_code FROM (SELECT MAX(stock_id) as stock_id, stock_div.stock_code, MAX(exdiv_date) as exdiv_date FROM stock_div GROUP BY stock_code ORDER BY `exdiv_date` DESC) abc "; $stockcode_array = $db->query($sql)->fetch_all(); foreach ($stockcode_array as $key => $stockcode) : ?> <?php $stock_code = $stockcode[0]; $sql = "SELECT * FROM stock_div WHERE stock_code=$stock_code ORDER BY exdiv_date DESC ,stock_id DESC "; $stock_info = $db->query($sql)->fetch_assoc(); .....some code here.... ?> //End of the PHP dynamic data //HTML table start.... <div class="block"> <div id="<?php echo $stock_code;?>" class="table" onclick="location.href='stock_details.php?stock_code=<?php echo $stock_code;?>';" style="cursor: pointer;"> <div class="row"> <label for="stockCode">Stock Code</label> <input disabled="true" name="stockCode" value="<?php echo $stock_code;?>"></input> </div> <div class="row"> <label for="stockName">Stock Name</label> <input disabled="true" name="stockName" value="<?php echo $stock_info['stock_name'];?>"></input> </div> <div class="row"> <label for="exDiv">Ex-Div Date</label> <input disabled="true" name="exDiv" value="<?php echo $stock_info['exdiv_date'];?>"></input> </div> <div class="row"> <label for="yield">Yield</label> <input disabled="true" name="yield" class="yield" value="<?php echo sprintf("%.1f%%", $stock_info['stock_yield']);?>"></input> </div> <div class="row"> <label for="prob3">P(<3d)</label> <input disabled="true" name="prob3" value="<?php echo sprintf("%.0f%%", ($p3/$dataSize)*100);?>"></input> </div> <div class="row"> <label for="prob5">P(<5d)</label> <input disabled="true" name="prob5" value="<?php echo sprintf("%.0f%%", ($p5/$dataSize)*100);?>"></input> </div> <div class="row"> <label for="prob10">P(<10d)</label> <input disabled="true" name="prob10" value="<?php echo sprintf("%.0f%%", ($p10/$dataSize)*100);?>"></input> </div> <div class="row"> <label for="prob20">P(<20d)</label> <input disabled="true" name="prob20" value="<?php echo sprintf("%.0f%%", ($p20/$dataSize)*100);?>"></input> </div> <div class="row"> <label for="prob30">P(<30d)</label> <input id="prob30" disabled="true" name="prob30" value="<?php echo sprintf("%.0f%%", ($p30/$dataSize)*100);?>"></input> </div> <div class="row"> <label for="size">Data Size</label> <input disabled="true" name="size" value="<?php echo $dataSize;?>"></input> </div> </div></div> //HTML table end.... <?php endforeach; ?> ------------------------------------------------------------------------------------------------------