Skip navigation.
Home

archives

echo "using echo sucks!";

Wonky Code

Nicely formatted, easy to read, but oh so wrong. The switch is bad enough but using all those echo makes me so angry. I pity all pour souls that have to work with code like this.

<?php
if(@$_POST['vote'] == TRUE)
{
   switch (@
$_POST['bewertung'])
       {
           case
"1":
             
$punkt = 1;
             break;
           case
"2":
             
$punkt = 2;
             break;
           case
"3":
             
$punkt = 3;
             break;
           case
"4":
             
$punkt = 4;
             break;
           case
"5":
             
$punkt = 5;
             break;
            case
"6":
             
$punkt = 6;
             break;
            case
"7":
             
$punkt = 7;
             break;
           case
"8":
             
$punkt = 8;
             break;
             case
"9":
             
$punkt = 9;
             break;
             case
"10":
             
$punkt = 10;
             break;
         }
mysql_query("INSERT INTO bewertung(repID,punkte) VALUES ('$repID','$punkt')");
}

/* hier kommt nur die Ausgabe der Puntkte nich relevant*/

echo "<table border=0 width=80 cellspacinng=0 cellpadding=0>";
echo
"  <tr>";
echo
"   <td>";
echo
"     <form method=\"post\" type=\"text/css\" action=\"http://www.example.com/index.php?section=Replays\">";
echo
"        <select name=\"bewertung\" size=\"1\">";
             for (
$bew = 1 ; $bew &lt;= 10 ; $bew++)
                     {
                       echo
"<option>".$bew."</option>";
                     }
echo
"   </td>";
echo
"   <td>";
echo
"              <input type=\"submit\" value=\"Vote\" name=\"vote\">";
echo
"            </form>";
echo
"   </td>";
echo
"  </tr>";
echo
"</table>";
?>

When I was your age I didn't have luxuries like...

Bad Architecture

being able to select more than one column from the database at a time!
(thanks to Nightflyer for this submission)