Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Moin,

ich habe hier eine 1*1 Tabelle erstellt 

<body>
<table>
<?php

    $spalte="1";
 
 echo "<table border='1'>\n";

while($spalte<=10){
     
 
     echo "\t<tr>\n";
 $zeile="1";
    
while($zeile<=10){
        
        $ergsp=$zeile*$spalte;
		echo "\t\t<td>$ergsp</td>\n";
    	$zeile++;
    } 
     
       echo "\t</tr>\n";
       $spalte++;
 }
	?>
</table>
</body>

Jetzt will ich alle gerade und ungerade zahlen markieren und komme nicht so richtig weiter , brauche ein paar tipps in diese richtung 

 

  • Autor
vor 53 Minuten schrieb Interrupt:

Hallo,

schau dir dazu mal den Modulo Operator an. 

https://code.tutsplus.com/tutorials/how-to-use-the-modulo-operator-in-php--cms-32393

https://de.wikipedia.org/wiki/Division_mit_Rest

Falls du immer noch Schwierigkeiten haben solltest, dann solltest du mal genauer Beschreibung wo du hängst. 😉

MfG

 

<body>
<table>
<?php

    $spalte="1";
 
 echo "<table border='1'>\n";

while($spalte<=10){
     
 
     echo "\t<tr >\n";
 $zeile="1";
    
while($zeile<=10){
        
        $ergsp=$zeile*$spalte;
		
        if($ergsp % 2 == 0){        echo "\t\t<td bgcolor=#FF0000>$ergsp</td>\n";
        } else {echo "\t\t <td  bgcolor=#00FF7F>$ergsp</td>\n";}
$zeile++;
    } 
     
       echo "\t</tr>\n";
       $spalte++;
 }
	?>
</table>
</body>

ich habe es so gelöst , vielen dank für die hilfe! 

In diesem Zusammenhang solltest du dir mal CSS anschauen. Das Design sollte nicht im HTML-Dokument gemacht werden, sondern in CSS. Das macht änderungen später einfacher, weil das Design an einer Stelle definiert wird und nicht überall verteilt.

https://jsfiddle.net/xvoLr16h/

<!DOCTYPE html> 

<html> 
  <head>
    <style>
        table {
          border: 1px solid black;
        }

        .even {
          color: red;
        }

        .odd {
          color: black;
        }
     </style>	
   </head>
   <body> 
      <table>
        <tr>
        <td class="odd">1</td>
          <td class="even">2</td>
          <td class="odd">3</td>
          <td class="even">4</td>
          <td class="odd">5</td>
          <td class="even">6</td>
          <td class="odd">7</td>
          <td class="even">8</td>
          <td class="odd">9</td>
          <td class="even">10</td>
        </tr>
        <tr>
          <td class="even">2</td>
          <td class="even">4</td>
          <td class="even">6</td>
          <td class="even">8</td>
          <td class="even">10</td>
          <td class="even">12</td>
          <td class="even">14</td>
          <td class="even">16</td>
          <td class="even">18</td>
          <td class="even">20</td>
        </tr>
      </table>
      ...
   </body> 
</html>

 

  • Autor
vor 7 Minuten schrieb Whiz-zarD:

In diesem Zusammenhang solltest du dir mal CSS anschauen. Das Design sollte nicht im HTML-Dokument gemacht werden, sondern in CSS. Das macht änderungen später einfacher, weil das Design an einer Stelle definiert wird und nicht überall verteilt.

https://jsfiddle.net/xvoLr16h/

<!DOCTYPE html> 

<html> 
  <head>
    <style>
        table {
          border: 1px solid black;
        }

        .even {
          color: red;
        }

        .odd {
          color: black;
        }
     </style>	
   </head>
   <body> 
      <table>
        <tr>
        <td class="odd">1</td>
          <td class="even">2</td>
          <td class="odd">3</td>
          <td class="even">4</td>
          <td class="odd">5</td>
          <td class="even">6</td>
          <td class="odd">7</td>
          <td class="even">8</td>
          <td class="odd">9</td>
          <td class="even">10</td>
        </tr>
        <tr>
          <td class="even">2</td>
          <td class="even">4</td>
          <td class="even">6</td>
          <td class="even">8</td>
          <td class="even">10</td>
          <td class="even">12</td>
          <td class="even">14</td>
          <td class="even">16</td>
          <td class="even">18</td>
          <td class="even">20</td>
        </tr>
      </table>
      ...
   </body> 
</html>

 

war mein erster gedanke , ich wollte es zuerst mit php/html lösen , css geht immer . danke für den vorschlag

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.