Announcement

Collapse
No announcement yet.

Using elseif

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using elseif

    Hi

    Can someone tell me the elseif code that disallows a user joining a team if their userID is already in clanID. Take a look at the attatchment, it shows when user (ID -> 325) joins a team (ID -> 187), it allows it multiple of times.
    Attached Files

  • #2
    The below should work, just change the table parameters.
    [PHP]
    } else{
    $num = mysql_num_rows(mysql_query("SELECT clan FROM `users` WHERE `username` = '".$username."'"));
    if($num > 0){
    echo "You are already in a clan.";
    [/PHP]
    Webhosting.UK.com || cPanel VPS Hosting || Reseller Hosting

    Sales: 0808-262-0855
    Support: 0800-612-8725
    International: +44 191 303 8191

    Comment


    • #3
      I'm already using else. Here is all the code, not sure where to put this in.



      Code:
      	$result2 = safe_query("SELECT * FROM ".PREFIX."cup_clan_members WHERE userID = '$userID' && clanID = '$clanID'");
      		if(mysql_num_rows($result2)==3)
      		echo '<center><b>You already are in 3 teams!</b><br>Please leave a team first.</center>';
      
      ==================
      ADD HERE?
      ==================
      
      	else{
      		$result = safe_query("SELECT * FROM ".PREFIX."cup_all_clans ORDER BY name ASC");		
      		$clan .= '<option value="0" selected="selected"> - Please choose a Team - </option>';
      		while($ds=mysql_fetch_array($result)) {
      			$clan .= '<option value="'.$ds[ID].'">'.$ds[name].'</option>';
      		}
      Thanks.
      Last edited by karimali831; 20-02-10, 02:13 PM.

      Comment


      • #4
        So I couldn't get across with php so I looked into phpmyadmin and I set clanID and userID as unique and this seems to work. Only problem is, the error is produced like this:

        # Query failed: errorno=1062
        # error=Duplicate entry '187-325' for key 2
        # query=INSERT INTO ficocup_cup_clan_members (clanID, userID, function) VALUES ('187', '325', 'Member')

        can't it be changed so user understands?

        Comment

        Working...
        X