hallo zusammen,
das hier ist mein script
	
kann mir jemand sagen wie ich jetzt ein bild einfüge und das dann verknüpfe mit dem "wechsle die farbe" button
sinn ist: das die farbe des autos sich dann ändert; hinterlegt werden sollen 2 bilder (rotes, blaues auto)
LG 
							
						
					das hier ist mein script
PHP Code:
	
	
<?php
session_start();
class Car {
    protected $color = 'red';
    protected $maximumKM = 450;
    protected $restKM = 450;
    protected $currentKM = 0;
    protected $kmPerDrive = 73;
    public function toggleColor() {
        if ($this->isRed()) {
            $this->color = 'blue';
            return;
        }
        $this->color = 'red';
    }
    private function isRed() {
        return $this->color === 'red';
    }
    public function drive() {
        if ($this->restKM > $this->kmPerDrive) {
            $this->currentKM += $this->kmPerDrive;
            $this->restKM -= $this->kmPerDrive;
        }
    }
    public function fillTank() {
        $this->restKM = 450;
    }
    public function getColor() {
        return $this->color;
    }
    public function getDrivenKM() {
        return $this->currentKM;
    }
    public function getRestKM() {
        return $this->restKM;
    }
}
if (isset($_SESSION['car'])) {
    $car = unserialize($_SESSION['car']);
} else {
    $car = new Car();
}
if (isset($_GET['drive'])) {
    $car->drive();
    $_SESSION['car'] = serialize($car);
}
if (isset($_GET['fill'])) {
    $car->fillTank();
    $_SESSION['car'] = serialize($car);
}
if (isset($_GET['toggleColor'])) {
    $car->toggleColor();
    $_SESSION['car'] = serialize($car);
}
?>
<html>
    <div style="position:absolute; top:7.1px; right:680px">
      
      <a href="?toggleColor">
        <button>Wechsle die Farbe</button>
      </a>
        <br>
      <a href="?fill">
        <button>auftanken</button>
      </a>
        <br>
      <a href="?drive">
        <button>fahre weiter...</button>
      </a>
        
    </div>
 
  <h3>Übersicht</h3>
  <table border="0">
      <tr>
        <td><h4>Farbe: </h4></td>
        <td><p><?= $car->getColor() ?></p></td>
      </tr>
      <tr>
         <td><h4>Gefahrene KM: </h4></td>
         <td><p><?= $car->getDrivenKM() ?></p></td>
     </tr>
     <tr>
         <td><h4>Restfüllung: </h4></td>
         <td><p><?= $car->getRestKM() ?></p></td>
     </tr>
  </table>
</html>
sinn ist: das die farbe des autos sich dann ändert; hinterlegt werden sollen 2 bilder (rotes, blaues auto)
LG
 
							
						 
          
Comment