Jump to content

exit(); BEFORE last else?


Bradley99

Recommended Posts

Sup guys,

 

I have some if elseif code to determine what should be shown if x = y (DUH).

 

The if elseif part works fine. I.e if x=y then it echo's what it should, and if x=z it echo's what it should. But it ALSO displays what's underneath the if elseif.

 

Here's the code:

<?
$pickdone = mysql_query("SELECT * FROM fights WHERE event='$viewevent' AND id NOT IN (SELECT fight_id FROM betting WHERE user_id='$user->id')");
$nofights = mysql_query("SELECT * FROM fights WHERE event='$viewevent'");
if ( mysql_num_rows( $nofights ) == 0 )
echo "<table class='thinline' cellpadding='0' cellspacing='0' width='85%'>
<tr>
<td class='Tableheading'><font color='#ff8a00'><b>There are currently no scheduled fights for this event, please check back soon.</b></font></td></tr></table>
<BR>"; 

elseif ( mysql_num_rows( $pickdone ) == 0 )
echo "<table class='thinline' cellpadding='0' cellspacing='0' width='85%'>
<tr>
<td class='Tableheading'><font color='#ff8a00'><b>You have completed your picks for this event, please check back after '$fetch->date' to see your score.</b></font></td></tr></table>
<BR>";


else

?>

 

I tried adding an exit(); before the last else, but that doesn't work. Any help is appreciated. (Oh and i know I'm terrible at explaining my problems HA)

Link to comment
Share on other sites

Your trying to check two different condition's, so the if statement only needed but twice.

 

<?php
$pickdone = mysql_query("SELECT * FROM fights WHERE event='$viewevent' AND id NOT IN (SELECT fight_id FROM betting WHERE user_id='$user->id')");
$nofights = mysql_query("SELECT * FROM fights WHERE event='$viewevent'");

if ( mysql_num_rows( $nofights ) == 0 ){

echo "<table class='thinline' cellpadding='0' cellspacing='0' width='85%'>
<tr>
<td class='Tableheading'><font color='#ff8a00'><b>There are currently no scheduled fights for this event, please check back soon.</b></font></td></tr></table>
<BR>"; 
}

if ( mysql_num_rows( $pickdone ) == 0 ){
echo "<table class='thinline' cellpadding='0' cellspacing='0' width='85%'>
<tr>
<td class='Tableheading'><font color='#ff8a00'><b>You have completed your picks for this event, please check back after '$fetch->date' to see your score.</b></font></td></tr></table>
<BR>";
}
?>

Link to comment
Share on other sites

I told you i was crap at explaining.

 

If the first is true, the first echo should show, then exit.

If the second if true, the second echo should show, then exit.

If neither is true, the code displayed BELOW that PHP should show.

 

But what's happening is, it's show BOTH the Echo & the code displayed below.

Link to comment
Share on other sites

Alright, I changed the code, and the if query works, but again it displays the code below when the query is true, so it displays the echo AND the code below.

 

Full Code:

<?
$viewevent=$_GET['viewevent'];
$bonusdone = mysql_query("SELECT * FROM betting WHERE user_id='$user->id' AND fight_id='0'");
if ( mysql_num_rows( $bonusdone ) == 1 )
echo "<table class='thinline' cellpadding='0' cellspacing='0' width='85%'>
<tr>
<td class='Tableheading'><font color='#ff8a00'><b>You have completed your Bonus Award picks for this event, please check back after '$fetch->date' to see your score.</b></font></td>
</tr><tr><td class='subtableheader'>Make sure you've completed all your fight picks above</td></tr></table>
<BR>";


else

?>
<?

if ($_POST['Submit1']){
$fotn_id = $_POST['fotn_id'];
$sotn_id = $_POST['sotn_id'];
$kootn_id = $_POST['kootn_id'];

{
mysql_query("INSERT INTO betting (`bet_id` , `event_id` , `fight_id` , `user_id` , `fighter_id`, `method`, `round`, `bonus`, `fotn_id`, `sotn_id`, `kootn_id`)
VALUES ('', '$fetch->id', '0', '$user->id', '0', '0', '0', '0', '$fotn_id', '$sotn_id', '$kootn_id' )") or die (mysql_error());
$url = '?viewevent=$viewevent';
echo "Your bonus pick is in, Good Luck <META HTTP-EQUIV=Refresh CONTENT='1'; URL='.$url.'>";

}}
?>

<table class="main" align"left" style='table-layout:fixed' cellpadding="2"
cellspacing="0" rules="none" width="100%">
<col width=40>
<col width=20>
<col width=20>
<col width=20>
    <tbody>
      <tr>
        <td  colspan="4" align="left" class="TableHeading">
		 <b><?php echo "$viewevent"; ?> Bonus Picks</b></td>
      </tr>
      <tr>
        <td class="subtableheader"  width="40%">Fight of the Night:</td>
        <td class="subtableheader"  width="20%">KO of the Night:</td>
        <td class="subtableheader"  width="20%">Submission of the Night:</td>
        <td class="subtableheader"  width="20%">Finished:</td>
      </tr>
   
	  <form action='' method='post'><tr>                <td class="profilerow" ><select name="fotn_id">      
<?php
$select_fotn = mysql_query("SELECT id, fighter1, fighter2 FROM fights WHERE event='$viewevent' ORDER by id ASC");
while($the=mysql_fetch_object($select_fotn)){
	echo "<option value=\"" .$the->id . "\">" .$the->fighter1 .  _vs_  .$the->fighter2 . "</option>\r";
}
?>
</select></td>
	  <td class="profilerow"><select name="kootn_id">      
<?php
$select_sotn = mysql_query("SELECT id, fighter1, fighter2 FROM fights WHERE event='$viewevent' ORDER by id ASC");
while($the=mysql_fetch_object($select_sotn)){
	echo "<option value=\"" .$the->fighter1 . "\">" .$the->fighter1 . "</option>\r
	      <option value=\"" .$the->fighter2 . "\">" .$the->fighter2 . "</option>\r";
}
?>
</select></td>
	  <td class="profilerow" ><select name="sotn_id">      
<?php
$select_kootn = mysql_query("SELECT id, fighter1, fighter2 FROM fights WHERE event='$viewevent' ORDER by id ASC");
while($the=mysql_fetch_object($select_kootn)){
	echo "<option value=\"" .$the->fighter1 . "\">" .$the->fighter1 . "</option>\r
	      <option value=\"" .$the->fighter2 . "\">" .$the->fighter2 . "</option>\r";
}
?>
</select></td>
	  <input type='hidden' name='fight_id' value='$the->id'>	  
	  <td class='profilerow'><input type='Submit' name='Submit1' value='Pick' class='Submit' /> </td></form>
  		  </tr></tbody></table>
</center>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.