0

hello friends i'm using the boostrap menu for my website it was fine until i wanted to get menu element from database so u got the syntax error unexpected '<' in line 3 and the line 5, 6, 7, 9, 10, are shown red in my IDE i gues if i solve the line 3 i will get the same message for that lines too !

<?php
            while($row=mysqli_fetch_array($sqldonee, MYSQLI_ASSOC)){
             <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
                <li role="separator" class="divider"></li>
                <li><a href="#">Separated link</a></li>
                <li role="separator" class="divider"></li>
                <li><a href="#">One more separated link</a></li>
              </ul>
            </li>
            ?>

Edited by chrisschristou: more detail

2
Contributors
4
Replies
33
Views
11 Months
Discussion Span
Last Post by diafol
2

How experienced are you with PHP? You can't have raw text inside a loop. It needs to be echoed. In any case the code above makes no sense. You aren't echoing anything from the DB.

0

not expert! so i took time try fix it seems like i found what was wrong but i found i litle problem, no error or warning but the echo is not echoing something

<?php 
    include('./db/cnntdb.php');
    $sqlrecup= "SELECT * FROM main";
    $sqldonee= mysqli_query($cnndb, $sqlrecup) or die('could not get data');
    while($row=mysqli_fetch_array($sqldonee, MYSQLI_ASSOC)){
        //echo $row['main']; this can diplay the data if i delet the comment but echo in li tag below doesn't display anything
    }
?>
<?php do { ?>
            <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php echo $row['main']; ?><span class="caret"></span></a>
              <ul class="dropdown-menu">
                <li><a href="#">Action</a></li>
                <li role="separator" class="divider"></li>
                <li><a href="#">Separated link</a></li>
                <li role="separator" class="divider"></li>
                <li><a href="#">One more separated link</a></li>
              </ul>
            </li>
            <?php } while ($row=mysqli_fetch_assoc($sqldonee));?>
0

The first mysqli_fetch_array loop, although you comment out actions, moves the internal data pointer ahead to the end. So, the second time you call it, it has nowhere to go as the internal pointer is at the end. Comment out the first loop entirely and it may work.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.