0

I will develop website using bootstrap, php, js and mysql. I have connect the db dynamically using php(hotel menu table). I have one side bar, in the center table menu, right side ordernow billing process. In this table i cant fetch all the row from the db line bulk of 244 rows(it just loading.......not display anything).(10 0r 20 finely working). I am using phpstorm 7.1.3(IDE) . I can use the below code:

<div class="col-md-8">
    <?

    $dbhost = '127.0.01';
    $dbuser = 'root';
    $dbpass = 'root';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass);

    if (!$conn)
    {
        die('Could not connect: ' . mysql_error());
    }

    mysql_select_db('hotpot');

    $sql = 'SELECT * FROM Menu';

    $retval = mysql_query( $sql);
    $numrows = mysql_num_rows( $retval);
    /*echo "<script type='text/javascript'>alert('$numrows')</script>";*/
    echo $numrows;
    echo "Fetched data successfully\n";
    mysqli_close($conn);

    ?>

    <input type="search" class="light-table-filter" data-table="order-table" placeholder="Filter">
    <table id="table" class="order-table table">
        <thead id="tablehead">
        <tr>
            <th>ID</th>
             <th>CATEGORY</th>
             <th>FOOD_TYPE</th>
            <th>FOOD ITEM</th>
            <th>PRICE</th>
            <th>QUANTITY</th>
            <th>CART</th>
        </tr>
        </thead>
        <tbody>
        <?php
        ini_set('max_execution_time', 5); //300 seconds = 5 minutes----------->i can use this one but it will not work
        if( mysql_num_rows( $retval )==0 ){
            echo '<tr><td colspan="4">No Rows Returned</td></tr>';
        }else{

            while( $row = mysql_fetch_assoc( $retval)){

             echo "<tr><td id='food_id'>{$row['ID']}</td>
             <td id='category'>{$row['CATEGORY']}</td>
             <td id='food_type'>{$row['FOOD_TYPE']}</td>
            <td id='item'>{$row['ITEM']}</td>
            <td id='price'>{$row['PRICE']}</td>
            <td ><input  id='uniqueIdentifier' type='number' name='input' value='1' max='50' min='1' class='order-count'></td>
            <td><i class='fa fa-plus-circle'  onmouseover='links=false;' onmouseout='links=true;'  onclick='if(links)addB()'></i></td></tr>\n";

            }
        }
        ?>
        </tbody>
    </table>
</div>
Cœur
  • 37,241
  • 25
  • 195
  • 267
Razul
  • 99
  • 1
  • 12
  • Remove this `mysqli_close($conn);` - first you are using mysql_ not mysqli_, second you shouldn't close connection before get data – nospor May 25 '16 at 14:07
  • use mysqli driver, and may be switch to a PHP framework with make life easy working with DB, Adding index to MySQL table will also improve performance of MySQL – Faraz May 25 '16 at 14:13
  • Please dont use [the `mysql_` database extension](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php), it is deprecated (gone for ever in PHP7) Specially if you are just learning PHP, spend your energies learning the `PDO` database extensions. [Start here](http://php.net/manual/en/book.pdo.php) its really pretty easy – RiggsFolly May 25 '16 at 14:18

0 Answers0