navigation.php

<div id="navigation">

<div id="logo"><img src="images/logo2.png" width="160" height="60"></div>

<?php

include('include/con_database.php');

$result2 = mysql_query("SELECT menu_name FROM menu_order WHERE menu_id='1'");

while ($data2 = mysql_fetch_array($result2)){

echo '<td>'.$data2['menu_name'].'</td>'.'<br>';

}
?>

<div id='cssmenu'>
  <ul>
     <li class='active'><a href='index.php'>|&nbsp&nbsp&nbsp&nbspHome&nbsp&nbsp&nbsp&nbsp|</a></li>
     <li class='has-sub'><a href='index.php'>&nbsp&nbsp&nbsp&nbspProduct & Services&nbsp&nbsp&nbsp&nbsp|</a>
        <ul>
           <li class='onelayer'><a href='connection.php'>&nbsp&nbsp&nbsp&nbspConnection &nbsp&nbsp&nbsp&nbsp&nbsp <img src="images/arrow.png"></a>
              <ul>
                 <li class='onelayer'><a href='vsat.php'>&nbsp&nbsp&nbsp&nbspVSAT</a></li>
                 <li class='onelayer'><a href='terestrial.php'>&nbsp&nbsp&nbsp&nbspTerestrial</a></li>
              </ul>
           </li>
           <li class='onelayer'><a href='collaboration.php'>&nbsp&nbsp&nbsp&nbspCollaboration&nbsp&nbsp&nbsp <img src="images/arrow.png"></a>
              <ul>
                 <li class='onelayer'><a href='cloud.php'>&nbsp&nbsp&nbsp&nbspCloud</a></li>
                 <li class='onelayer'><a href='ucom.php'>&nbsp&nbsp&nbsp&nbspUnified &nbsp&nbsp&nbspCommunication</a></li>
                 <li class='onelayer'><a href='cc.php'>&nbsp&nbsp&nbsp&nbspContact Center</a></li>
                 <li class='onelayer'><a href='surveillance.php'>&nbsp&nbsp&nbsp&nbspSurveillance Center</a></li>
              </ul>
           </li>
           <li class='onelayer'><a href='solution.php'>&nbsp&nbsp&nbsp&nbspSolution&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <img src="images/arrow.png"></a>
                <ul>
                </ul>
           </li>
        </ul>
     </li>
     <?php /* <li><a href='agent.php'>&nbsp&nbsp&nbsp&nbspAgent&nbsp&nbsp&nbsp&nbsp|</a></li> */ ?>
     <li><a href='aboutus.php'>&nbsp&nbsp&nbsp&nbspAbout Us&nbsp&nbsp&nbsp&nbsp|</a></li>
     <li><a href='contactus.php'>&nbsp&nbsp&nbsp&nbspContact Us&nbsp&nbsp&nbsp&nbsp|</a></li>
  </ul>
</div>


<div id="search">
<input type="text" name="search" placeholder="search.." value=""></div>
<div id="sbutton"><img src="images/search button.jpg"></div>
</div>

</div>

hello, I am trying to make this code shorter:

<?php

include('include/con_database.php');

$result2 = mysql_query("SELECT menu_name FROM menu_order WHERE menu_id='1'");

while ($data2 = mysql_fetch_array($result2)){

echo '<td>'.$data2['menu_name'].'</td>'.'<br>';

}
?>

so that I can place it in between the navigation. Is there any way to do so?

Recommended Answers

All 5 Replies

Firstly, you should use padding. Now it is unreadable. Example:

<!DOCTYPE html>
<html>
<head>
<style>
li {
  display: inline;
}
a {
  padding-left: 25px;
  padding-right: 25px;
}
</style>
</head>
<body>
<ul>
<li>
<a href="http://www.w3schools.com">Visit W3Schools.com!</a>
</li>
<li>
<a href="http://www.w3schools.com">Visit W3Schools.com!</a>
</li>
<li>
<a href="http://www.w3schools.com">Visit W3Schools.com!</a>
</li>
</ul>

</body>
</html>

Secondly, your table is incorrect. You don't have at least <table> tags and <tr> tags which are required. Make code correct to avoid some bugs.

Still don't know what are you trying.
And I don't think there is shorter way you can grab data from DB.

Post print screen of what you get and describe what would you like because this incorrect code can't be followed.

okay, besides the padding. what about the connection to the database.

I mean this code:

    <?php
    include('include/con_database.php');
    $result2 = mysql_query("SELECT menu_name FROM menu_order WHERE menu_id='1'");
    while ($data2 = mysql_fetch_array($result2)){
    echo '<td>'.$data2['menu_name'].'</td>'.'<br>';
    }
    ?>

That code retrieve "Home". how to make it shorter since it's too long.

It seems shortest way for retrieving data from DB.

Is my code already the shortest code to retrieve and print the data from DB ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.