From what I've read, it isn't possible to echo more PHP code within an echo so I'm after a solution to the following:
Basically, if the 'closed_state' column in my DB equals 'yes', display a link with a variable on the end else display a different link with a variable on the end.
Here's my code:
<?php
$result1 = mysqli_query($con,"SELECT closed_state FROM tbl_company WHERE company_id='$company_id'") or die(mysql_error());
$result2 = mysqli_query($con,"SELECT company_id FROM tbl_company WHERE company_id='$company_id'") or die(mysql_error());
$result3 = mysqli_query($con,"SELECT company_id FROM tbl_company WHERE company_id='$company_id'") or die(mysql_error());
while($row = mysqli_fetch_array($result1))
{
if ($row['closed_state'] == "yes")
{
echo "<a href="customers_open.php?company_id=<?php while($row = mysqli_fetch_array($result2)) echo "{$row['company_id']}"; ?>">Reopen account</a>";
} else {
echo "<a href="customers_close.php?company_id=<?php while($row = mysqli_fetch_array($result3)) echo "{$row['company_id']}"; ?>">Close account</a>";
}
}
?>
Obviously it doesn't work so what's the best way to achieve this?