I am writing a if statement that if the two dates listed are equal it echo’s the first date and if the they aren’t(else statement) it echoes “date1-date2” I have it inside a function and I do not know if I am alowed to do that.Here is the error I am getting
Parse error: syntax error, unexpected T_IF
Here is my function:
function getfevent ($conn) {
$sql = "SELECT `name` FROM `event` WHERE `featured` = 0 LIMIT 0, 30 ";
$statement=$conn->prepare($sql);
$statement->execute();
while($row=$statement->fetch()) {
$eventname = $row['name'];
$row_id=geteventid ($conn,$eventname);
$row_end=geteventend ($conn,$eventname);
$date=if ($row_id == $row_end){
echo $row_id;
}
else {
echo $row_id " - " $row_end;
}
?>
<?php echo "<td>$eventname</td><td>$date</td></tr>"; ?>
<?php
}
}
getfevent($conn);
Probably you want this.
Don’t forget. Use
.to concat.It’s the same of