传递变量以获取正确的消息

时间:2015-05-30 13:39:53

标签: php

我无法传递两个变量来获取要显示的正确语句我可以得到一个或另一个但不是两个都因此我不得不暂时注释掉其中一个语句。

 <?php   
  if(strtotime($row['entry_cutoff_date']) < strtotime($today))
  <td style='text-align: center;  padding-top:30px; padding-bottom:30px;'><a href='event-list.php' style="background:#428bca; border: 5px solid #000; box-shadow: 5px 5px 3px #666666; font-size: 16px; height: 65px;line-height: 16px; padding: 15px 30px; width: 137px; color:#FFF;"><b> Closed <?php // echo $row ['entry_cutoff_date'];?></b></a><br><br>
  if(strtotime($row['accept_entries_date']) > strtotime($today))
 {?>
  <td style='text-align: center;  padding-top:30px; padding-bottom:30px;'><a href='event-list.php' style="background:#428bca; border: 5px solid #000; box-shadow: 5px 5px 3px #666666; font-size: 16px; height: 65px;line-height: 16px; padding: 15px 30px; width: 137px; color:#FFF;"><b>Registration opens on <?php echo $row['accept_entries_date'];?></b></a><br><br>-->


      </td> 
     <?php
     }
     else
     { ?>
         <td style='text-align: center;'><a href='event.php'><img style='width: 137px; height: 65px;' alt='' src='images/signup_button.jpg' border='0'></a><br><hr>
      </td>
     <?php
     }?> 

提前致谢!

XXXX以下代码适用于一个变量,并让我知道正确的事件ID:

<?php                if(strtotime($row['entry_cutoff_date']) <   strtotime($today))
        {?>
        <td style='text-align: center;  padding-top:30px; padding- bottom:30px;'><a href='event-list.php' style="background:#428bca; border: 4px  solid #000; box-shadow: 1px 1px 

        3px #666666; font-size: 16px; height: 65px;line-height: 16px; padding: 15px 30px; width: 147px; color:#FFF;"><b>Closed</b></a><br><br>
  </td>
  <?php
  }
else
{ ?>
<td style='text-align: center;'> 

<form name="ingfrm" action="event.php" method="post">
<input type="hidden" name="txtevent_id" id="txtevent_id" value="<?php echo   $_SESSION['event_id']; ?>" >
<input type="submit"  style='background-image:   url(images/signup_button.jpg); color: transparent; width: 143px; height: 80px;'   alt='' border='0' name="submitimage" value="signup">
</form>

<br><br>
  </td>
<?php
  }?> 

这就是我显示的正确消息,但现在注册按钮没有转到正确的事件ID

if(strtotime($row['entry_cutoff_date']) < strtotime($today)){
    $tstyle = ' padding-top:30px; padding-bottom:30px;';
    $output = "<a href='event-list.php' style='background:#428bca; border:    5px solid #000; box-shadow: 5px 5px 3px #666666; font-size: 16px; height:   65px;line-height: 16px; padding: 15px 30px; width: 137px; color:#FFF;'><strong>   Closed ".$row['entry_cutoff_date']."</strong></a><br /><br />";
}elseif(strtotime($row['accept_entries_date']) > strtotime($today)){
    $tstyle = ' padding-top:30px; padding-bottom:30px;';
    $output = "<a href='event-list.php' style='background:#428bca; border:  5px solid #000; box-shadow: 5px 5px 3px #666666; font-size: 16px; height: 65px;line-height: 16px; padding: 15px 30px; width: 137px; color:#FFF;'><strong>Registration opens on ".$row['accept_entries_date']."</strong></a><br /><br />";
}else{
    $tstyle = '';
    $output = "<a href='event.php'><img style='width: 137px; height: 65px;'   alt='' src='images/signup_button.jpg' border='0'></a><br /><hr />";
}
?>

1 个答案:

答案 0 :(得分:0)

您的代码存在一些问题。在第一个变量中,$ row和array之间有一个空格。你也没有正确关闭或重新打开你的php标签。最后你的花括号没有被正确地表达,这是我解释你想要的输出的清理版本;

rowCount()

或者

PDO::MYSQL_ATTR_FOUND_ROWS

编辑给用户更新的代码:

<?php   
    if(strtotime($row['entry_cutoff_date']) < strtotime($today)){
        $output = "<td style='text-align: center;  padding-top:30px; padding-bottom:30px;'><a href='event-list.php' style='background:#428bca; border: 5px solid #000; box-shadow: 5px 5px 3px #666666; font-size: 16px; height: 65px;line-height: 16px; padding: 15px 30px; width: 137px; color:#FFF;'><b> Closed ".$row['entry_cutoff_date']."</b></a><br><br></td>";
    }elseif(strtotime($row['accept_entries_date']) > strtotime($today)){
        $output = "<td style='text-align: center;  padding-top:30px; padding-bottom:30px;'><a href='event-list.php' style='background:#428bca; border: 5px solid #000; box-shadow: 5px 5px 3px #666666; font-size: 16px; height: 65px;line-height: 16px; padding: 15px 30px; width: 137px; color:#FFF;'><b>Registration opens on ".$row['accept_entries_date']."</b></a><br><br></td>";
    }else{
        $output = "<td style='text-align: center;'><a href='event.php'><img style='width: 137px; height: 65px;' alt='' src='images/signup_button.jpg' border='0'></a><br><hr></td>";
    }

    echo $output;

?>
相关问题