Hello Please forgive me if I'm not asking this right. I have the following code.
<?php
//Connect to mysql server
include ("Data.php");
if (!$con) {
die ("connection error". mysqli_connect_error());
}
$sql1 = "SELECT * FROM PMList where AssetNum= '$AssetNum' and Plant= '$Plant';";
$result = mysqli_query($con, $sql1) or die(mysqli_error($con));
if ($result->num_rows > 0)
$count = 0;
$Task = 1;
while($row = mysqli_fetch_array($result))
{
$Task++;
echo "<td bgcolor='#D8D8D8' align='Left'>";
echo "<font size='2'>";
echo $row['Task$Task'];
echo " </font></td>";
echo "<td bgcolor='#D8D8D8'><input type='radio' name='Task$Task' value='Yes'>Yes";
echo " <input type='radio' name='Task$Task' value='No'>No";
echo "<tr border='0'>";
}
while ($count++ < 16) {
}
$con->close();
?>
What I am trying to do is add the $task value to the echo $row['Task$Task']; So that the value turns to task1 then task2 , task3 ect. There can be up to 15 tasks. I'm close just not sure on where I'm messing up. Any help would be great. been stuck on this one for awhile now. Thank you in advance!!
OK now this is what I have its displaying almost correctly.
$sql1 = "SELECT * FROM PMList where AssetNum= '$AssetNum' and Plant= '$Plant';";
$result = mysqli_query($con, $sql1) or die(mysqli_error($con));
if ($result->num_rows > 0)
$count = 0;
$Task = 1;
while($row = mysqli_fetch_assoc($result))
do
{
echo "<td bgcolor='#D8D8D8' align='Left'>";
echo "<font size='2'>";
echo $row['Task'.$Task];
echo " </font></td>";
echo "<td bgcolor='#D8D8D8'><input type='radio' name='Task$Task' value='Yes'>Yes";
echo " <input type='radio' name='Task$Task' value='No'>No";
echo "<tr border='0'>";
$Task++;
}
while ($count++ <= 13);
$con->close();
?>
Now it is looping however, If the task is empty I need to not echo the radio buttons and stop where it ends. capture. Thank you guys your all awesome!! How do I add a if statement thst can see if the $row['Task'.$Task]; is null then stop the loop?