Im new to php and mysql and doing my final year project, i want to ask u ppl that what if i want to display a row of a table after some if condition, i want to diplay offered courses to all the students and if the student whose course is accepted i dont want to display <th>action</th> in that row.. iam wondering how would i do that, please help me solve the problem, thanks in advance

<?php
   $con=mysql_connect($dbserver,$dbusername,$dbpassword);
if (!$con)
    {
   die('Could not connect: ' . mysql_error());
    }
mysql_select_db($dbname, $con);
$result = mysql_query("SELECT courses.id AS cid, courses.title, courses.subjectsid, subjects.id AS sid, subjects.subjectname,  requestrecord.status
FROM courses JOIN subjects ON courses.subjectsid = subjects.id 
LEFT JOIN requestrecord 
ON courses.id = requestrecord.coursesid AND requestrecord.accountsid=".$_SESSION['id']);

echo "<table border='1' style='width:500px;'> <br />
<tr>
<th>Course Name</th>
<th>Subject </th>
<th>Action</th>
<th>Status</th>

</tr>";
while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
    echo "<td>" . $row['title'] . "</td>";
    echo "<td>" . $row['subjectname'] . "</td>";
    echo "<td><a href='request-for-approval.php?id=".$row['cid']."& sid=".$row['sid']."'>Apply!</a></td>"; 
    echo "<td>" . $row['status'] . "</td>";
  echo "</tr>";
    }
echo "</table>";
mysql_close($con);
?>
Member Avatar for LastMitch

@Riu 2009

i want to diplay offered courses to all the students and if the student whose course is accepted i dont want to display <th>action</th> in that row..

I'm very confused of what you are asking?

You mean you want to delete a row from the DB?

Then used this:

$sql = "DELETE FROM table WHERE row =''";

If this is not what you asking. Then explain a little more what you talking about.

@LastMitch
no i donot want to remove a row from db i donot want to display

echo "<td><a href='request-for-approval.php?id=".$row['cid']."& sid=".$row['sid']."'>Apply!</a></td>"; 

when the status is applied

basically i want to remove the option for apply if user already applied hope u understand my question

How about something like:

echo "<td>";
if ("I must display") {
    echo "<a href='request-for-approval.php?id=".$row['cid']."& sid=".$row['sid']."'>Apply!</a>";
}
else {
    echo "&nbsp;";
}
echo "</td>";

yeah sort of :) thanx for ur responce

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.