I attached screen shot with this thread. how we display data from database without null values.

As most people, I don't like downloading files from the internet without knowing what might be inside. Either explain your problem better, or post some code. A screenshot is useless.

~G

Member Avatar for rajarajan2017

Hey you dont have values in the databse, thats why? if you avoided that then how could you display other things in that relevant row? if you want to show something instead of null then check with the loop for empty values and assign some string in that row while display.

Note: If you want to show one more screenshot, no need to start a new thread, attached in your already existing thread.

i cant attached document in existing thread. there is no option. "Insert Link" only available.

Member Avatar for rajarajan2017

No you have to use the advanced editor for that. See guidelines. Okay. What about my queries regarding your issue?

additem.php

<script type="text/javascript">
function showUser(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getite.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form action="getite.php">
<h3><a href="getitem.php">Add Item</a></h3><br/>

<?php
error_reporting(0);
    mysql_connect("localhost","root","");
    mysql_select_db("menus") or die(mysql_error());

$query="SELECT DISTINCT main FROM smenu";


$result = mysql_query ($query);
echo "<select name='sers' onchange='showUser(this.value)'>";
// printing the list box select command

while($nt=mysql_fetch_array($result)){
echo "<option value='$nt[main]'>$nt[main]</option>";



}

echo "</select>";


?> 
<div id="txtHint"><b>Items info will be listed here.</b></div>
</form>
</body>
</html>

getite.php

<?php
$q=$_GET["q"];
echo "$q";
error_reporting(0);
    mysql_connect("localhost","root","");
    mysql_select_db("menus") or die(mysql_error());


    $sql="SELECT * FROM smenu WHERE main = '".$q."'";

$result = mysql_query($sql);


         mysql_close($con);
         echo "<table width=800 border=1 cellspacing=2>";
        echo "<tr bgcolor=#ccccc>";
        echo " <th width=100 height=34 scope=col>Item</th>";
        echo "<th width=500 scope=col><div align=center>Description</div></th>";
        echo "<th width=300 scope=col><div align=center>Category</div></th>";
        echo "<th width=94 scope=col>Rate</th>";
        echo "<th width=94 scope=col>Order Item</th>";
        echo "</tr>";

         while($row=mysql_fetch_array($result))
         {
         echo "<tr><td align='center'>";
         echo $row['itemm']; 
         echo "</td><td align='left'>";
         echo $row['descrip'];
         echo "</td><td align='center'>";
         echo $row['Category'];
         echo "</td><td align='center'>";
         echo $row['Rate'];
         echo "</td><td align='center'>";
         echo "order this";

         }
         echo "</table>";

            ?>

</body>
</html>

If Click "order this", then the particular item goes to separate database. How to do this..

Member Avatar for rajarajan2017
while($row=mysql_fetch_array($result))
{
echo "<tr><td align='center'>";
echo $row['itemm']; 
echo "</td><td align='left'>";
echo $row['descrip'];
echo "</td><td align='center'>";
$check = $row['Category'];
if ($check == ' '  or $check == Null)
	echo 'NILL';
else
	echo $row['Category'];
echo "</td><td align='center'>";
echo $row['Rate'];
echo "</td><td align='center'>";
echo "order this";

}
echo "</table>";
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.