How do i make it so that if a field in the database is left empty it ignores that echo when i collect the data? Like i mean if someone is not maried so they have no wife can i make it so that the wifename field does not show?
<?php
// First connect to database
$host = "localhost";
$dbuser = "email";
$dbpass = "qwe";
$db = "roth";
$con = mysql_connect($host, $dbuser, $dbpass);
if(!$con){
die(mysql_error());
}
$select = mysql_select_db($db, $con);
if(!$select){
die(mysql_error());
}
// Now collect all info into $item variable
$item = $_REQUEST['find'];
// This will take all info from database where row tutorial is $item and collects it into $data variable
$data = mysql_query("SELECT * FROM email_contact_list WHERE firstname LIKE '%$item%'");
// This creates a loop which will repeat itself until there are no more rows to select from the database. We getting the field names and storing them in the $row variable. This makes it easier to echo each field.
while($row = mysql_fetch_array($data)){
echo $row['lastname']. " "; echo $row['firstname']. "<br>";
echo $row['wifename']. "<br>";
echo $row['address']. "<br>";
echo $row['city']. "<br>";
echo $row['province']. "<br>";
echo $row['pc']. "<br>";
echo $row['phone']. "<br>";
echo $row['email']. "<br>";
echo $row['date_entered']. "<br>";
echo $row['connection']. "<br>","<hr>";
}
?>