How to hide download button if i do not want to upload a song

hello
i am working on music project. I have a big problem that i dont wanna show the download button if i dont upload song. Like, i can upload maximum 8 songs in my project but if the album have 5 songs or more or less , then i dont want to show the download button. please help me. this is my code:
<?php
include_once(“config.php”);

			 $albumname=$_REQUEST['id'];
			  $m="select * from hindiaudio where albumname='$albumname'";
			  $n=mysql_query($m);
			  echo"&lt;table border='2' width='200%' height='200px'&gt;
			  &lt;tr&gt;
			  &lt;th&gt;SONG_NAME&lt;/th&gt;&nbsp;&nbsp;&nbsp;&nbsp;
			
			  &lt;th&gt;DOWNLOAD &lt;/th&gt;&nbsp;
			
			  &lt;/tr&gt;";
			  while($row=mysql_fetch_array($n))
			  {
				  echo"&lt;tr&gt;";
				
		echo"&lt;td&gt;&lt;center&gt;".$row['name1']."&lt;/td&gt;";
		
		
		echo"&lt;td&gt;&lt;center&gt;&lt;a href='downloadhindiaud1.php?id=".$row['code1']."'&gt;DOWNLOAD&lt;/a&gt;"."&lt;/td&gt;";
		
		echo"&lt;/tr&gt;";
		echo"&lt;tr&gt;";
				
		echo"&lt;td&gt;&lt;center&gt;".$row['name2']."&lt;/td&gt;";
		
					echo"&lt;td&gt;&lt;center&gt;&lt;a href='downloadhindiaud2.php?id=".$row['code2']."'&gt;DOWNLOAD&lt;/a&gt;"."&lt;/td&gt;";
					echo"&lt;/tr&gt;";
		echo"&lt;tr&gt;";
				
		echo"&lt;td&gt;&lt;center&gt;".$row['name3']."&lt;/td&gt;";
		
					echo"&lt;td&gt;&lt;center&gt;&lt;a href='downloadhindiaud3.php?id=".$row['code3']."'&gt;DOWNLOAD&lt;/a&gt;"."&lt;/td&gt;";
					echo"&lt;/tr&gt;";
		echo"&lt;tr&gt;";
				
		echo"&lt;td&gt;&lt;center&gt;".$row['name4']."&lt;/td&gt;";
		
		
		echo"&lt;td&gt;&lt;center&gt;&lt;a href='downloadhindiaud4.php?id=".$row['code4']."'&gt;DOWNLOAD&lt;/a&gt;"."&lt;/td&gt;";
		
		echo"&lt;/tr&gt;";
		echo"&lt;tr&gt;";
				
		echo"&lt;td&gt;&lt;center&gt;".$row['name5']."&lt;/td&gt;";
		
		
		echo"&lt;td&gt;&lt;center&gt;&lt;a href='downloadhindiaud5.php?id=".$row['code5']."'&gt;DOWNLOAD&lt;/a&gt;"."&lt;/td&gt;";
					echo"&lt;/tr&gt;";
					echo"&lt;tr&gt;";
				
		echo"&lt;td&gt;&lt;center&gt;".$row['name6']."&lt;/td&gt;";
		
		
		echo"&lt;td&gt;&lt;center&gt;&lt;a href='downloadhindiaud6.php?id=".$row['code6']."'&gt;DOWNLOAD&lt;/a&gt;"."&lt;/td&gt;";
					echo"&lt;/tr&gt;";
					echo"&lt;tr&gt;";
				
		echo"&lt;td&gt;&lt;center&gt;".$row['name7']."&lt;/td&gt;";
		
		
		echo"&lt;td&gt;&lt;center&gt;&lt;a href='downloadhindiaud7.php?id=".$row['code7']."'&gt;DOWNLOAD&lt;/a&gt;"."&lt;/td&gt;";
					echo"&lt;/tr&gt;";
					echo"&lt;tr&gt;";
				
		echo"&lt;td&gt;&lt;center&gt;".$row['name8']."&lt;/td&gt;";
		
		
		echo"&lt;td&gt;&lt;center&gt;&lt;a href='downloadhindiaud8.php?id=".$row['code8']."'&gt;DOWNLOAD&lt;/a&gt;"."&lt;/td&gt;";
					echo"&lt;/tr&gt;";
			  }
			
				
			  echo"&lt;/table&gt;";
			
			  ?&gt;

You’ll need to clarify the question I’m afraid. Where does the upload come into it?

If you’re asking about how to not show the download button if, for example, one of your rows doesn’t have all eight tracks, just surroung the echo() statements for that entry with a check for there being something in $row[‘codex’].

So I’d do something like this pseudo-code:


$q = "select * from songs where albumid = '$albumid' ";
$result = $dbc->prepare($q);
$result->execute();
if ($result) {
  while ($row = $result->fetch()) {
    echo '<table>';
   $i = 1;
    while ($i<9) {
      if ($row['code' . $i] <> "") {   ' or whatever you use for an empty field
        echo '<tr><td>' . $row['name' . $i] . '</td><td><a href=wherever>Download</a></td></tr>';
        }
      $i++;
     }
    }
   }

That won’t work as typed, and it also uses PDO instead the older soon-to-be-disabled mysql functions. It will only display the table row and the download link if there’s something in the $row variable called code1, code2 and so on. It’s not intended to be directly-working code, only to show how I’d lay it out. Rather than individually coding each table row, have a loop for however many is your maximum number of tracks per album.

Come back with more detail if I’ve totally misunderstood the question.

sorry and thank you for your reply.
Actually the above code is fetching on client site.

And here is code of upload songs on admin site,

<?php


	session_start();	
include_once("config.php");


if($_SERVER['REQUEST_METHOD']=='POST')
if(isset($_POST['aud_name1']))
if(isset($_POST['aud_name2']))
if(isset($_POST['aud_name3']))
if(isset($_POST['aud_name4']))
if(isset($_POST['aud_name5']))
if(isset($_POST['aud_name6']))
if(isset($_POST['aud_name7']))
if(isset($_POST['aud_name8']))
	{
	$picture=$_FILES['picture']['name'];
	$hindialbum=$_POST['name'];
	$artist=$_POST['artist'];
	$v=$_FILES['picture']['tmp_name'];
move_uploaded_file("$v","pbiaudimages/".$picture);
$name1=$_POST['aud_name1'];
$b1=$_FILES['audio1']['name'];
$c1=$_FILES['audio1']['tmp_name'];
$type1=$_FILES['audio1']['type'];
move_uploaded_file("$c1","punjabiaudios/".$b1);
$name2=$_POST['aud_name2'];
$b2=$_FILES['audio2']['name'];
$c2=$_FILES['audio2']['tmp_name'];
$type2=$_FILES['audio2']['type'];
move_uploaded_file("$c2","punjabiaudios/".$b2);
$name3=$_POST['aud_name3'];
$b3=$_FILES['audio3']['name'];
$c3=$_FILES['audio3']['tmp_name'];
$type3=$_FILES['audio3']['type'];
move_uploaded_file("$c3","punjabiaudios/".$b3);
$name4=$_POST['aud_name4'];
$b4=$_FILES['audio4']['name'];
$c4=$_FILES['audio4']['tmp_name'];
$type4=$_FILES['audio4']['type'];
move_uploaded_file("$c4","punjabiaudios/".$b4);
$name5=$_POST['aud_name5'];
$b5=$_FILES['audio5']['name'];
$c5=$_FILES['audio5']['tmp_name'];
$type5=$_FILES['audio5']['type'];
move_uploaded_file("$c5","punjabiaudios/".$b5);
$name6=$_POST['aud_name6'];
$b6=$_FILES['audio6']['name'];
$c6=$_FILES['audio6']['tmp_name'];
$type6=$_FILES['audio6']['type'];
move_uploaded_file("$c6","punjabiaudios/".$b6);
$name7=$_POST['aud_name7'];
$b7=$_FILES['audio7']['name'];
$c7=$_FILES['audio7']['tmp_name'];
$type7=$_FILES['audio7']['type'];
move_uploaded_file("$c7","punjabiaudios/".$b7);
$name5=$_POST['aud_name8'];
$b8=$_FILES['audio8']['name'];
$c8=$_FILES['audio8']['tmp_name'];
$type8=$_FILES['audio8']['type'];
move_uploaded_file("$c8","punjabiaudios/".$b8);
				$query1="insert into punjabiaudio(picture,albumname,artist,name1,code1,name2,code2,name3,code3,name4,code4,name5,code5,name6,code6,name7,code7,name8,code8) values('$picture','$hindialbum','$artist','$name1','$b1','$name2','$b2','$name3','$b3','$name4','$b4','$name5','$b5','$name6','$b6','$name7','$b7','$name8','$b8')"or die(mysql_error());
		if(mysql_query($query1))
		header("location:punjabiaudios.php");
		 	{
			echo "<script> alert('album added sucessfully') </script>";	
			}	
			
	}
	else
		{
			
			$hindialbum='';
			$artist='';
			$name1='';
			$b1='';
			$name2='';
			$b2='';
			$name3='';
			$b3='';
			$name4='';
			$b4='';
			$name5='';
			$b5='';
			$name6='';
			$b6='';
			$name7='';
			$b7='';
			$name8='';
			$b8='';
			
			
			
		}
?>

And this is html code:

<form name="hindiupload" onSubmit="return validate();" action=""  method="post" enctype="multipart/form-data">
<table>
<tr><td>
        Picture for punjabi album: </label></td><td><input type="file" class="form_input_contact" name="picture" value=""/>
	</td></tr>
	<tr><td>
    Punjabi Album name: </label></td><td><input type="text" name="name" rows="" cols="" value=""></input></td></tr>
	<tr><td>
    Artist: </label></td><td><input type="text" name="artist" rows="" cols="" value=""></input></td></tr>
   <tr><td>
<div align="center">
<h3><font color="#000000">UPLOAD SONGS</font></h3><br>
<font color="#FFFFFF">

</font></div></td></tr><tr><td>
Name1:<input type="text" name="aud_name1"  ></td></tr><tr><td>
video1:<input type="file" name="audio1"></td></tr>
<tr><td>
Name2:<input type="text" name="aud_name2"  ></td></tr><tr><td>
video2:<input type="file" name="audio2"></td></tr>
<tr><td>
Name3:<input type="text" name="aud_name3"  ></td></tr><tr><td>
video3:<input type="file" name="audio3"></td></tr>
<tr><td>
Name4:<input type="text" name="aud_name4"  ></td></tr><tr><td>
video4:<input type="file" name="audio4"></td></tr>
<tr><td>
Name5:<input type="text" name="aud_name5"  ></td></tr><tr><td>
video5:<input type="file" name="audio5"></td></tr>
<tr><td>
Name6:<input type="text" name="aud_name6"  ></td></tr><tr><td>
video6:<input type="file" name="audio6"></td></tr>
<tr><td>
Name7:<input type="text" name="aud_name7"  ></td></tr><tr><td>
video7:<input type="file" name="audio7"></td></tr>
<tr><td>
Name8:<input type="text" name="aud_name8"  ></td></tr><tr><td>
video8:<input type="file" name="audio8"></td></tr>

<tr><td>
<input type="submit" /></td></tr>
</form>

I think now you can understand all this.
Problem is that i dont want to show the download button if there should be no song uploaded.

OK, so you’re uploading up to eight songs, and you want to present them for download, but if you only uploaded four songs you only want four download links? That would be pretty similar to the sample code I listed above - just run a loop around the eight name fields, and only list them if they’re not blank. If you prefer to use the code you listed in the first post instead of a loop, just surround each song with a check to see if there’s anything in the row for that song:


if ($row['code7']<>"") {
  echo"<tr>";
  echo"<td><center>".$row['name7']."</td>";
  echo"<td><center><a href='downloadhindiaud7.php?id=".$row['code7']."'>DOWNLOAD</a>"."</td>";
  echo"</tr>";
  }

Looking at your upload php code, does that work as-is? It seems there are a few things in there that would stop it, but I’m not all that experienced with real live code so I might be wrong.

yes it works.
Thank you so much.