I am using this query below and it only returns the first query in the entry if i use only the if (empty($field1)) to display. If i fill in the print(""); it works but i want to use the if (empty($field1)) snippet to display. How can i do it?
$sql="SELECT field1, field2 FROM table WHERE p_id='$pid'
and k_id='$kid' ORDER BY id DESC";
$result=mysql_query($sql);
$query = mysql_query($sql) or die ("Error: ".mysql_error());
if ($result == "")
{
echo "";
}
echo "";
$rows = mysql_num_rows($result);
if($rows == 0)
{
print("");
}
elseif($rows > 0)
{
while($row = mysql_fetch_array($query))
{
$field1 = $row['field1'];
$field2 = $row['field2'];
print("");
}
}
if (empty($field1)) {
echo ""; //Thats right, i don't want anything to show for this portion
} else {
echo "<div id=comments>Comments</div><br>
<div id=entries>$field1 and $field2</div>";
}
p_idandk_id?field1andfield2, but later you are using$row['field1_name']and$row['field2_id'].$field1and$field2