-1

I am working on a project that users apply for events. The pertinent code I have now is as follows:

      <? if(in_array($u_id, $app)){ ?>
          <td>Unapply:</td>
          <td><a href="event_unapply.php?event_id=<?=$e_id; ?>">Unapply</a></td>
      <? } else{ ?>
           <td>Apply:</td>
           <td><a href="event_apply.php?event_id=<?=$e_id; ?>">Apply!</a></td>
      <? }?>

Now if a user is applied, the print_r of the array looks like:

Array ( [0] => Array ( [id] => 3 [Userid] => 1 ) )

$u_id matches the [Userid] in the event but it always goes to the else statement.

I tried doing $app['0'] but then every time the user is not applied for an event, it returns a PHP error.

Does anyone have an idea to make it so it would work?

Matt
  • 137
  • 1
  • 10
  • 3
    Please don't rely on short open tags, but use proper / sane ` – PeeHaa Dec 29 '12 at 21:33
  • What is the harm in using short tags? – Matt Dec 29 '12 at 21:34
  • Mainly portability. And sanity. – PeeHaa Dec 29 '12 at 21:36
  • 1
    @Matt, [Are PHP short tags acceptable to use?](http://stackoverflow.com/q/200640/417685) – Alexander Dec 29 '12 at 21:36
  • In all honesty, I have been using short tags for years. I don't plan on changing hosts. The script will never be released. The script will never even be looked at by anyone but me. I chose to use short tags. It's my decision. You chose to use long. That's yours. So if you think I'm 'insane' because I use short tags, then so be it. But downvoting my question just because I don't obide by your 'rules' is childish in my opinion. – Matt Dec 29 '12 at 21:47

1 Answers1

-1

Nvmd, had a tad of a brain fart but I got it working correctly by using:

      <? if($u_id == $app['0']['Userid']){ ?>
          <td>Unapply:</td>
          <td><a href="event_unapply.php?event_id=<?=$e_id; ?>">Unapply</a></td>
      <? } else{ ?>
           <td>Apply:</td>
           <td><a href="event_apply.php?event_id=<?=$e_id; ?>">Apply!</a></td>
      <? }?>
Matt
  • 137
  • 1
  • 10