0

I am trying with php 7.0 as everyone recommend me here to start with it as 5.6 has been depreveted . But after writing its code i am unable to fetch the values from database. what wrong i am doing here. thank you

//This is my aboutus page//

<div class="col-lg-10">
    <?php  include('config.php');
    $query = mysqli_query('select * from about ');
    while($row = mysqli_fetch_array($query)){
    ?>

    <h5>
    <?php echo $row['about_desc'] ;?>
    <br>
    <br>
    <?php echo $row['about_desc1']; ?>
    <br>
    <br>
    <?php echo $row['about_desc2'] ;?>
    <br>
    <br>
    <?php echo $row['about_desc3'] ;?>
    <br>
    <br>
    <?php echo $row['about_desc4']; ?> 

    </h5>
    <hr class="featurrate-divider">
    <?php
    }
    ?>
    </div>
</div>

<div id="tab-1">
    <?php  include('config.php ');
    $query = mysqli_query('select * from news LIMIT 0,2');
    while($row = mysqli_fetch_array($query)){
    ?>
    <div class="news">
        <h4><u><?php echo $row['news_name']; ?></u></h4>
        <h5><font color="black"><?php echo $row['dat']; ?></font></h5>

        <p><?php echo $row['news_desc']; ?></p>
        <a href="index.php?con=8">se mer >></a>
    </div>
    <hr class="featurrate-divider">

    <?php
    }
    ?>
</div>

//This is my config.php file//

<?php
$connection = mysqli_connect('localhost','root','','dandelion') or die(mysqli_error($connection));
?>

Looking for good suggestion as a learner. thank you

9
  • 1
    mysqli_query() need first parameter as your connection!! Commented Jul 21, 2016 at 9:31
  • @Saty can you please explain me .thank you Commented Jul 21, 2016 at 9:31
  • Please remove everything that does not cause the problem. Right now you have bunch of html that has nothing to do with your question. Improve readability as much as you can if you want good answers! Commented Jul 21, 2016 at 9:32
  • okey i will @Al.G. Commented Jul 21, 2016 at 9:33
  • 4
    Use you query as mysqli_query($connection,'select * from about '); Commented Jul 21, 2016 at 9:33

2 Answers 2

1

Your About us page should be like this:

<body>

                                <div class="col-lg-10">
                                    <?php  include('config.php');
                    $query = mysqli_query($connection, 'select * from about ');
                    while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
                       ?>

                         <h5>
                        <?php echo $row['about_desc'] ;?>
                                            <br>
                                                <br>
                                                    <?php echo $row['about_desc1']; ?>
                                                    <br>
                                                        <br>
                                                            <?php echo $row['about_desc2'] ;?>
                                                            <br>
                                                                <br>
                                                                    <?php echo $row['about_desc3'] ;?>
                                                                    <br>
                                                                        <br>
                                                                            <?php echo $row['about_desc4']; ?> 

                    </h5>
                    <hr class="featurrate-divider">
                                        <?php
                                        }
                                        ?>
                </div>
                </div>

                                <div id="tab-1">
                                     <?php  include('config.php ');
                                    $query = mysqli_query($connection, 'select * from news LIMIT 0,2');
                                    while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
                                       ?>
                                    <div class="news">
                                        <h4><u><?php echo $row['news_name']; ?></u></h4>
                                         <h5><font color="black"><?php echo $row['dat']; ?></font></h5>

                                         <p><?php echo $row['news_desc']; ?></p>
                                        <a href="index.php?con=8">se mer >></a>
                                    </div>
                                    <hr class="featurrate-divider">

                                    <?php
                                    }
                                    ?>
                                </div>



</body>
Sign up to request clarification or add additional context in comments.

1 Comment

thank you @techie code.. yes i got my error.. thank you so much .
0

if your database connection is sucessfully work and problem with fetching data than use number.it may be useful to fetch the data.

<?php echo $row[o]; ?>

<?php echo $row[1]; ?>

instead of

<?php echo $row['about_desc1']; ?> 

1 Comment

actually i m wrong here in mysqli_query($connection ,$query); . I am missing the $connection .. thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.