Can't echo out..pleas help


<?php 
		if(isset($row[image1]))
		{
		echo "<a href='DLfile.php?download_file=$image1'>File 1</a> $nbsp";
		}
		if(isset($row[image2]))
		{
		echo "<a href='DLfile.php?download_file=$image2'>File 2</a> $nbsp";
		}
		if(isset($row[image3]))
		{
		echo "<a href='DLfile.php?download_file=$image3'>File 3</a> $nbsp";
		}
	?>

Hi - what doesnt echo?
also

if(isset($row[image1]))

should be

if(isset($row['image1']))

where is $image1 declared?

$nbsp should be  

My guess would be that either the $row array or the image# constants aren’t “set”.

i have re-edit my code many times to different condition just to echo out the link.but it doesn’t echo out the link.

my idea is if the data which i got in the database is not Null then link must now show up but if there is no data it must not echo out. but it always show the opposite to what i want.

this is my code for the query



$attach=mssql_query("Select * from tblTicket inner join tblattachment on tblTicket.TickNo=tblattachment.TicketNo ");


while($row=mssql_fetch_array($attach)){
	$id=$row['id'];
	$Cday=$row['DateCreate'];
	$Cat=$row['Category'];
	$Ttime=$row['TimeCreate'];
	$SubCat=$row['Subcat'];
	$Desc=$row['Description'];
	$ticketno=$row['TickNo'];
	$image1=trim($row['image1']);
	$image2=trim($row['image2']);
	$image3=trim($row['image3']);
}

this must be echo out out if the condition is true.

	
<?php 
		if(isset($row['image1']))
		{
		echo "<a href='DLfile.php?download_file=$image1'>File 1</a> &nbsp";
		}
		if(isset($row['image2']))
		{
		echo "<a href='DLfile.php?download_file=$image2'>File 2</a> &nbsp";
		}
		if(isset($row['image3']))
		{
		echo "<a href='DLfile.php?download_file=$image3'>File 3</a> &nbsp";
		}
	?>

hope for your help.thanks.

figure it out i just edit it to this one.


<?php 
		if(!empty($image1))
		{
		echo "<a href='DLfile.php?download_file=$image1'>File 1</a> &nbsp";
		}
		if(!empty($image2))
		{
		echo "<a href='DLfile.php?download_file=$image2'>File 2</a> &nbsp";
		}
		if(!empty($image3))
		{
		echo "<a href='DLfile.php?download_file=$image3'>File 3</a> &nbsp";
		}
	?>

yep that would do it :slight_smile:

Add a ; to the end of the &nbsp


<?php
for ($i=1;$<=3;$i++)
{
  $image=${'image'.$i};
  if (!empty($image))
    echo '<a href="DLfile.php?download_file=', $image, '">File ', $i, '</a> &nbsp;';
}
?>

:slight_smile: