<body>
<p>
  <?php
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("select", $con);

$result = mysql_query("SELECT * FROM view");
?>
  </p>
<form id="form1" name="form1" method="post" action="">

  <table width="100%" border="1" cellspacing="0" cellpadding="0">
  <?php while($row = mysql_fetch_array($result))?>
   <?php  

                {
            ?>
            <tr bgcolor="#F5F5F5"> 
              <td > 
                <?php echo $val['name']; ?>
              </td>           
             </tr>
        <?php mysql_close($con);   
         }   ?>

  </table>  
   </form>  
</body>

hi, dear

Try this
<?php
$result=$val;

echo "<tr bgcolor="#F5F5F5"><td >".$result."</td></tr>";
?>

Problem is stil there :(
paste of error is shown at the end of the code.


<form id="form1" name="form1" method="post" action="">

<table width="100%" border="1" cellspacing="0" cellpadding="0">
<?php while($row = mysql_fetch_array($result))?>
<?php
{
?>
<?php
$result=$val;

echo "<tr bgcolor="#F5F5F5"><td >".$result."</td></tr>";
?>

<?php mysql_close($con);
} ?>

</table>
</form>

ERROR

Notice: Undefined variable: val in C:\wamp\www\danicolums\connectivity.php on line 32


LINE 32: $result=$val;

Hi,

Its not $val. Its a $row.

$result=$row['name'];

Hi, here is the code.....

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<table width="70%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td colspan="2">NAME RESULTS TO DISPLAY</td>
</tr>

<?php
$server = "localhost";
$username = "root";
$password = "";
$db_name = "select";
$db = mysql_connect($server,$username,$password) or DIE("Connection to database failed, perhaps the service is down !!");
$db1=mysql_select_db($db_name) or DIE("Database name not available !!");

$login = mysql_query("select name,Designation from view");

while ($row = mysql_fetch_array($login, MYSQL_ASSOC))
{
echo"<tr>";
echo "<td>" .$val= $row["name"]."</td>";
echo"<td>" .$val= $row["Designation"]."</td>";
echo "</tr>";
}
?>

</table>
</body>
</html>

@monica singh :
ya this was the one , i was waitin for..
this worked..

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.