---
title: "if elseif-sats?"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/155667-if-elseif-sats"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "eklof00"
published: "2007-01-07T20:50:01.000Z"
updated: "2007-01-07T22:30:06.000Z"
replies: 5
views: 412
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/155667-if-elseif-sats"
---

# if elseif-sats?

## #1 — eklof00, 2007-01-07T20:50Z

tip_tips är det som användaren tippar och lägger in i tabellen.

match_tips är det rätta tips som jag lägger in.

Meningen med denna if-sats är att:

right.gf visas om tip_tips är identiskt med match_tips, vilket fungerar.

samt att wrong.gif visas och tip_tips och match_tips inte är lika, detta funkar men.. 

Jag vill att det är tomt om match_tips fältet inte är ifyllt.

Måste jag ha en if-sats i if-satsen?

```php
if ($row['tip_tips'] === $row['match_tips']) {
	
	 echo '<td><img src="images/right.gif"></td>';
	  
	  }elseif ($row['tip_tips'] !== $row['match_tips']){ 
	  
	  echo '<td><img src="images/wrong.gif"></td>';
	  
	  }else{
	  echo "<td></td>";
	  
	}
```

Permalänk: https://www.webforum.nu/p/155667

## #2 — VictorY, 2007-01-07T20:58Z

Kan inte PHP, därför ger jag dig ingen kod, men ...

Om match_tips är lika med tip_tips: Rätt
Annars om match_tips är tomt: Tomt
Annars: Fel

Borde inte det fungera?

Permalänk: https://www.webforum.nu/p/1918669

## #3 — eklof00, 2007-01-07T21:01Z

Jo det fungerar. Men låt oss säga att användaren har tippat på en match som startar om 8 timmar.

Då vill jag inte få upp wrong.gif. Då vill jag ha blankt.

Permalänk: https://www.webforum.nu/p/1918671

## #4 — VictorY, 2007-01-07T21:03Z

Men i så fall är väl match_tips tomt? Eller?

Permalänk: https://www.webforum.nu/p/1918673

## #5 — vic, 2007-01-07T21:28Z

Nått sånt här kanske...

```

if(isset($row['tip_tips']))
	{
	if(empty($row['match_tips']))
		{
		echo 'Det finns inget matchtips ännu...';
		}
		elseif($row['tip_tips'] != $row['match_tips'])
			{
			echo '<img src="images/wrong.gif">';
			}
			else
			   {
			   echo '<img src="images/right.gif">';
			   }
	}
	else
		{
		echo 'Det finns inget tips';
		}
```

Permalänk: https://www.webforum.nu/p/1918676

## #6 — eklof00, 2007-01-07T22:30Z

Så här gjorde jag efter att ha sett din. tack!

```php
	  if(empty($row['match_tips'])){ 
echo '<td></td>'; 
} else{ 
 
if ($row['tip_tips'] == $row['match_tips']){ 
   echo '<td><img src="images/right.gif"></td>'; 
} elseif ($row['tip_tips'] != $row['match_tips']){ 
   echo '<td><img src="images/wrong.gif"></td>'; 
}
}
```

Permalänk: https://www.webforum.nu/p/1918692

---

Tråden på webben: https://www.webforum.nu/amne/php/155667-if-elseif-sats
