Jump to content

Stan007

New Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by Stan007

  1. Hello Barand,

    The problem is solved, this code that you  suggested fixed it:  'page' => $current_page,                                                            <-- CHANGED

    You really helped me thanks a lot, you have a new fan. Will be making donations pretty soon.

    Thanks again

    Stanley

  2. Guys thanks for helping me solve the problem i had but now i have another problem and i am lost. i have included the code below for you to have overview.


    On the home page the url shows how it should be: http://localhost/board/italian.php?country=Italian
    BUT 
    When you mouse over the NEXT link to go to next page you get this : http://localhost/board/?page=1&country=Italian  and then an error 404 when you click on the link
    page = 1  no matter if you are mousing over link for page 5 or 2

    This is the code:

    <table style="width:100%; margin-left:auto; margin-right:auto">
            <?php    
                
                $items_per_page = 5;//how many records/rows to display per page
                            
                $page_url      = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
                                        
                $cleaned_current_page_country = htmlspecialchars($_GET["country"]);
                            
                $page_number = (isset($_GET['page']))? filter_var($_GET['page']) : 1;
                //$page_number = filter_var($_GET['page']);
                //$page_number = $_GET['page'];
                    
                $selected_restaurant_type = $_GET['country'];
                                                                
                // find number of rows in the db
                    $query = "SELECT * FROM menu_update WHERE special_of_theday = 1 AND restaurant_type = '".$selected_restaurant_type."' ";
                    $query_result = mysqli_query($connection, $query); 
                    $row_count = mysqli_fetch_array($query_result);
                    $total_rows = mysqli_num_rows($query_result);
                                                    
                $expected_number_of_pages = ceil($total_rows/$items_per_page); //expected number of pages 
                                                    
                $page_position = (($page_number - 1) * $items_per_page); //get starting position to fetch record
                            
                //fetch a group of records using sql LIMIT clause
                    $query = "SELECT * FROM menu_update WHERE special_of_theDay = 1 AND restaurant_type = '".$selected_restaurant_type."' LIMIT " .$page_position. ',' .$items_per_page;
                    $query_result = mysqli_query($connection, $query);
            ?>
                            
                <table width="100%" border=0>
                    <tr bgcolor = "#cccccc">
                        <td>Meal</td>
                        <td>Meal name</td>
                        <td>Meal Price</td>
                        <td>Order Now</td>
                        <td>Full Menu</td>
                        <td>Our Gallery</td>
                        <td>Find Us</td>
                        <td>Our Chef</td>
                        <td>Our Manager</td>
                    </tr>
            <?php
                    while($row_count = mysqli_fetch_array($query_result)){
                        echo "<tr>";
                            echo"
                                <td style ='width:200px; text-align:center; height:120px; background:#eaedf2'><a href='meal_fullPic.php'><img src= ".$row_count['img']." /></a></td>
                                <td style ='width:119px; text-align:center; height:120px; background:#eaedf2'> ".$row_count['meal_name']."</td>
                                <td style ='width:100px; text-align:center; height:120px; background:#eaedf2'>".$row_count['price']."</td>
                                <td style ='width:100px; text-align:center; height:120px; background:#eaedf2'><a href='order_processor.php'><img src= ".$row_count['order_now']." /></a></td>
                                <td style ='width:100px; text-align:center; height:120px; background:#eaedf2'><a href='full_menu.php'><img src= ".$row_count['full_menu_img']." /></a></td>
                                        
                                <td style ='width:170px; text-align:center; height:120px; background:#eaedf2'><a href='restaurant_gallery.php'><img src= ".$row_count['restaurant_pic']." /></a></td>
                                <td style ='width:100px; text-align:center; height:120px; background:#eaedf2'><a href='restaurant_location.php'><img src= ".$row_count['location_pic']." /></a></td>
                                <td style ='width:119px; height:120px; background:#eaedf2'> ".$row_count['chef_name']."</td>
                                <td style ='width:119px; height:120px; background:#eaedf2'> ".$row_count['admin']."</td>
                            "; 
                        echo "</tr>";
                    }
                    mysqli_close($connection);
            ?>    
                </table>
            <div class="board_pagination">
            <?php
                //display the links to the pages
                for($current_page = 1; $current_page <= $expected_number_of_pages; $current_page++){
                     if ($page_number != $expected_number_of_pages){
                        $data = array(
                            'page' => $page_number,
                            'country' => $cleaned_current_page_country,
                        );
                        $the_query = http_build_query($data);
                        $page_url .= '?' . $the_query;
                        echo '<li><a href=" '.$the_query.' ">'.$current_page.'</a></li> ';
                    }
                }
            ?>
            </div>
        </table>
     

  3. this is what i want in the url 
    http://localhost/board/italian.php?page=2&country=italian

    when this link is clicked 
    echo "<a href='?page=".($page_number + 1)." ".(&)." country=".($cleaned_current_page_country)."'>Next</a>";

    but i keep getting this error:
    Parse error: syntax error, unexpected '&' in C:\xampp\htdocs\board\includes\menuboard_main_display.php on line 105

    appreciate any help

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.