Schleife:
<table>
<?php
for ($zeile=1; $zeile <= 5; $zeile++){
echo "<tr>";for ($spalte=1; $spalte <= 10; $spalte++){
echo "<td> $zeile Zeile, $spalte Spalte </td>";
}
echo "</tr>";
}
?>
</table>
<?php
$nur="Nur noch";
for ($zahl=25; $zahl>=0; $zahl--) {
if ($zahl >= 16) echo "<li style='color:#00FF80'>$nur $zahl</li>";
elseif($zahl>=6) echo "<li style='color:#FF8000'>$nur $zahl</li>";
elseif ($zahl>=1) echo "<li style=color:#FF0000'>$nur $zahl</li>";
}
?>
kkkk
if ($i%6 == 0) echo „<div class=’clear‘></div>“;
kkkk
if ($_GET)
{
print_r($_GET);
die();
}
kkkk
$aktueller_tag = date(„l“);
$aktuelles_datum= date(„d. m. Y.“);
$uhrzeit = date(„h:m:s“);
$time = date(„g:i:s a“);
$tag_neu = str_replace(„Thursday“, „Thurs.“, $aktueller_tag);
$zufallszahl = rand(0,100);
IP Adresse usw
$ip = $_SERVER[„REMOTE_ADDR“];
echo $ip;
echo „<br>“;
$sprache = $_SERVER[„HTTP_ACCEPT_LANGUAGE“];
echo $sprache;
echo „<br>“;
$sprache_kurz = substr($sprache, 0, 5);
echo $sprache_kurz;
kkkk
$ip = $_SERVER[„REMOTE_ADDR“];
echo $ip;
echo „<br>“;
$sprache = $_SERVER[„HTTP_ACCEPT_LANGUAGE“];
echo $sprache;
echo „<br>“;
$sprache_kurz = substr($sprache, 0, 5);
echo $sprache_kurz;
kkkkk
if ($_POST){
$richtiger_code = $_POST["n1"].$_POST["n2"].$_POST["n3"].$_POST["n4"];
// Auslesen der eingegebenen Antwort aus dem Formularfeld
$antwort = $_POST["antwort"];
if ($antwort == $richtiger_code) $feedback = „right“;
else $feedback = „wrong“;
}
kkkk
<?php
for ($bier=1; $bier<=$_POST["anzahl"]; $bier++) {
$preis = $_POST["preis"]*$bier;
echo "<tr>
<td class='right'>$bier</td>
<td>Bier</td>
<td class='right'>$preis</td>
<td>EUR</td>
</tr>";
}
?>
kkkk
<?php
$username=“seppi“;
$passwort=“joe123″;
if ($_POST) {
if ($username==$_POST[„user“]) {
echo“username ist richtig“;
}
else {
echo“username falsch“;
}
if ($passwort==$_POST[„pass“]) {
echo“ passwort ist richtig“;
}
else {
echo“ passwort falsch“;
}
}
?>
kkkk
<?php
$malzahl = 9;
if ($_GET[„malzahl“]) {
$malzahl = $_GET[„malzahl“];
}
if ($_GET[„anzahl“]) {
$anzahl = $_GET[„anzahl“];
}
else {
$anzahl = 10;
}
?>
<?php
for ($zaehler=1; $zaehler<=$anzahl; $zaehler++) {
$ergebnis = $zaehler*$malzahl;
echo "<tr style='background-color: #DDDDDD'>
<td style='text-align: center'>$zaehler</td>
<td style='text-align: center'>$malzahl</td>
<td style='text-align: center'>$ergebnis</td>
</tr>";
}
?>
kkkk
<?php
$bildanzahl=24;
if ($_GET){
$bildanzahl = $_GET[„bildanzahl“];}
else {$bildanzahl=24;}
?>
<form>
<input type=“number“ name=“bildanzahl“ min=1 max=24>
<input type=“submit“ value=“anzeigen“>
</form>
<?php
for ($i=1; $i<=$bildanzahl; $i++) {
echo "<div class='pin' style='background: #EEEEEE'>
<img src='img/$i.jpg' />
<p>Bild $i</p>
</div>";
}
?>
kkkk
$lotto = array();
for ($zaehler=1; $zaehler<=6; $zaehler++) {
$lotto[] = rand(1, 45);
}
// Schritt 3: Sortiere das Array
sort($lotto);
// Schritt 4: Gib alle Lottozahlen getrennt durch ein Komma aus
echo implode(„, “ , $lotto);
kkkk
$server („localhost“);
$user („niedermayrn“);
$pw („HighFive1!“);
$datenbank („niedermayrn_webshop“);
$conn=mysqli_connect($server,$user,$pw,$datenbank);
$sql = „SELECT * FROM ‚Bücher‘ WHERE ‚Genre=science fiction‘ DESC“;
$ergebnis=mysql_query($conn, $sql);
while ($datensatz = mysqli_fetch_assoc($ergebnis))
{
// Die Werte (Spalten) von jedem Datensatz in eine Variable zwischenspeichern (einfacher)
$vorname = $datensatz[„vorname“];
$nachname = $datensatz[„nachname“];
$email = $datensatz[„email“];
$telefon = $datensatz[„telefon“];
$strasse = $datensatz[„strasse“];
$plz = $datensatz[„plz“];
$ort = $datensatz[„ort“];
// Ausgabe der Werte
echo "<p class='entry'>
$vorname $nachname
<br><br>
$email
<br>
$telefon
<br><br>
$strasse
<br>
$plz $ort
</p>";
}