Reputation: 547
Alright, I have a table of tasks this table has a foreign key which is the "projectID"
I am selecting all the rows within that table that have the same projectID. But I now want to output the results in a list ("<li></li>
")
//Select tasks
$sql = "SELECT * FROM tasks WHERE projectID = '".$project_ID."'";
$result5 = $db->sql_query($sql);
$data5 = mysql_fetch_assoc($result5);
Upvotes: 0
Views: 56
Reputation: 82038
You're going to need to iterate through each of the rows and output the taskList column value:
$sql = "SELECT * FROM tasks WHERE projectID = '".$project_ID."'";
$result5 = $db->sql_query($sql);
$data5 = mysql_fetch_assoc($result5);
// this will let you handle an empty result set without a count.
if( $data5 )
{
// opening the list only if there are things to put there
echo "<ul >";
do
{
// output the value from one row.
echo "<li>" . $data5['taskName'].'</li>';
}while($data5 = mysql_fetch_assoc($result5));
echo "</ul>";
}
else
{
echo 'No tasks found!';
}
Upvotes: 1