Lehrerbenotung Lehrervoting
Skripte für MySQL und SQLite
Counter in PHP mit einfacher Textdatei als
Datenbank

geschrieben von Christoph für Petra Haars
 

Lehrerin: kleine, zierliche, blonde Svenja

1.Kriterium: guter Unterricht
Note 1
Note 2
Note 3
Note 4
Note 5
Note 6

1.306

2.Kriterium: cool und witzig
Note 1
Note 2
Note 3
Note 4
Note 5
Note 6

1.241

usw.

Skripte für MySQL


config.php


<?php
$server= "localhost";
$user= "root";
$passwort= "root";
$datenbank= "xy";
$verbindung= mysql_connect ($server, $user, $passwort) or die ("Es konnte keine
Verbindung zum Server hergestellt werden.");
mysql_select_db ($datenbank) or die ("Die Datenbank existiert nicht.");

?>


tabelle.php

<?php
include ('config.php');
$a= mysql_query("create table lehrerbenotung (id int (10) unsigned not null auto_increment, lehrer text,
guterunterricht int (10),
a int (10),
coolundwitzig int (10),
b int (10),
fachlichkompetent int (10),
c int (10),
motiviert int (10),
d int (10),
fairenoten int (10),
e int (10),
fairepruefungen int (10),
f integer,
menschlich int (10),
g int (10),
gutvorbereitet int (10),
h int (10),
vorbildlichesauftreten int (10),
i int (10),
beliebt int (10),
j int (10),
primary key (id)
) type=myisam; ");

?>


lehrereingabe.php

<?php
include ('config.php');
$a = "insert into lehrerbenotung (lehrer,guterunterricht,a,coolundwitzig,b) values ('svenja','0','0','0','0')";
$b= mysql_query($a);

?>


lehrerbenotung.php

<h2>Lehrerbenotung Skripte in MySQL<br>
und Sqlite<br>
&nbsp;</h2>

<b>Lehrerin: kleine, zierliche, blonde Svenja </b> <br><br>

<b><font color="#00FFFF">1.Kriterium: guter Unterricht </font></b>

<form method="POST" action= "lehrerbenotung.php">

<table width="200">
<tr>
<td>
Note 1<input type="radio" name="guterunterricht" value="1" >
</td>
</tr>

<tr>
<td>
Note 2<input type="radio" name="guterunterricht" value="2" >
</td>
</tr>

<tr>
<td>
Note 3<input type="radio" name="guterunterricht" value="3" >
</td>
</tr>

<tr>
<td>
Note 4<input type="radio" name="guterunterricht" value="4">
</td>
</tr>

<tr>
<td>
Note 5<input type="radio" name="guterunterricht" value="5">
</td>
</tr>

<tr>
<td>
Note 6<input type="radio" name="guterunterricht" value="6">
</td>
</tr>

<input type="hidden" name="a" value="1">
<input type="hidden" name="b" value="1">
<tr>
<td>

<input type="submit" name="submit" value="submit">

</td>
</tr>

</table>

</form>

</html>


<?php
include ('config.php');
$submit=$_POST["submit"];
$guterunterricht=$_POST["guterunterricht"];
$hidden=$_POST["a"];

if (!$guterunterricht)

{

}

else

{

$cc="update lehrerbenotung set guterunterricht = guterunterricht + $guterunterricht where id= '1'";
$dd= mysql_query($cc);
$ee="update lehrerbenotung set a= a + $hidden where id= '1' ";
$ff= mysql_query($ee);

}

$b= mysql_query ("select * from lehrerbenotung where id='1'");

$c= mysql_fetch_row($b);

$gesamt=$c[2];

$anzahl=$c[3];

if (!$anzahl)

{

}

else

{

echo round($gesamt/$anzahl,3);

}

?>

<html>

<br>
<br>

<b><font color="#00FFFF">2.Kriterium: cool und witzig </font></b>


<form method="POST" action= "lehrerbenotung.php">


<table width="200">
<tr>
<td>
Note 1<input type="radio" name="coolundwitzig" value="1" >
</td>
</tr>

<tr>
<td>
Note 2<input type="radio" name="coolundwitzig" value="2" >
</td>
</tr>

<tr>
<td>
Note 3<input type="radio" name="coolundwitzig" value="3" >
</td>
</tr>

<tr>
<td>
Note 4<input type="radio" name="coolundwitzig" value="4">
</td>
</tr>

<tr>
<td>
Note 5<input type="radio" name="coolundwitzig" value="5">
</td>
</tr>

<tr>
<td>
Note 6<input type="radio" name="coolundwitzig" value="6">
</td>
</tr>

<input type="hidden" name="a" value="1">
<input type="hidden" name="b" value="2">

<tr>
<td>

<input type="submit" name="submit" value="submit">

</td>
</tr>

</table>

</form>

</html>

<?php

include ('config.php');
$submit=$_POST["submit"];
$coolundwitzig=$_POST["coolundwitzig"];
$hidden=$_POST["a"];

if (!$coolundwitzig)

{

}

else

{

$cc="update lehrerbenotung set coolundwitzig = coolundwitzig + $coolundwitzig where id= '1'";
$dd= mysql_query($cc);
$ee="update lehrerbenotung set b= b + $hidden where id= '1' ";
$ff= mysql_query($ee);

}

$b= mysql_query ("select * from lehrerbenotung where id='1'");

$c= mysql_fetch_row($b);

$gesamt=$c[4];

$anzahl=$c[5];

if (!$anzahl)

{

}

else

{

echo round($gesamt/$anzahl,3);

}

?>


Skripte für SQLite


tabelleanlegen.php

<?php
$a=sqlite_open('xy');
sqlite_query ($a, "create table lehrerbenotung (id integer primary key, lehrer text,
guterunterricht integer,
a integer,
coolundwitzig integer,
b integer,
fachlichkompetent integer,
c integer,
motiviert integer,
d integer,
fairenoten integer,
e integer,
fairepruefungen integer,
f integer,
menschlich integer,
g integer,
gutvorbereitet integer,
h integer,
vorbildlichesauftreten integer,
i integer,
beliebt integer,
j integer )");

?>


lehrereingabe.php

<?php
$a=sqlite_open('xy');
sqlite_query($a, " insert into lehrerbenotung (lehrer,guterunterricht,a,coolundwitzig,b) values('svenja','0', '0','0','0')");

?>


abstimmen.php

<html>

<h2>Lehrerbenotung im Internet</h2>

Lehrerin: kleine, zirliche, freche, blonde svenja <br><br>

1.Kriterium: guter Unterricht

<form method="POST" action= "a.php">

<table width="200">

<tr>
<td>
Note 1<input type="radio" name="guterunterricht" value="1" >
</td>
</tr>

<tr>
<td>
Note 2<input type="radio" name="guterunterricht" value="2" >
</td>
</tr>

<tr>
<td>
Note 3<input type="radio" name="guterunterricht" value="3" >
</td>
</tr>

<tr>
<td>
Note 4<input type="radio" name="guterunterricht" value="4">
</td>
</tr>

<tr>
<td>
Note 5<input type="radio" name="guterunterricht" value="5">
</td>
</tr>

<tr>
<td>
Note 6<input type="radio" name="guterunterricht" value="6">
</td>
</tr>


<input type="hidden" name="a" value="1">
<input type="hidden" name="b" value="1">

<tr>
<td>
<input type="submit" name="submit" value="submit">
</td>
</tr>

</table>

</form>

</html>

<?php

$a=sqlite_open('xy');
$submit=$_POST["submit"];
$guterunterricht=$_POST["guterunterricht"];
$hidden=$_POST["a"];

if (!$guterunterricht)

{

}

else

{

sqlite_query($a, " update lehrerbenotung set guterunterricht = guterunterricht + $guterunterricht where id= '1'");
sqlite_query($a, " update lehrerbenotung set a = a + $hidden where id= '1'");

}

$b= sqlite_query($a, "select * from lehrerbenotung where id= '1' ");
while ($c= sqlite_fetch_array($b))

{

$gesamt=$c['guterunterricht'];

$anzahl=$c['a'];

if (!$anzahl)

{

}

else

{

echo round($gesamt/$anzahl,3);

}

}

?>

<html>

<br>
<br>

2.Kriterium: cool und witzig

<form method="POST" action= "a.php">


<table width="200">
<tr>
<td>
Note 1<input type="radio" name="coolundwitzig" value="1" >
</td>
</tr>

<tr>
<td>
Note 2<input type="radio" name="coolundwitzig" value="2" >
</td>
</tr>

<tr>
<td>
Note 3<input type="radio" name="coolundwitzig" value="3" >
</td>
</tr>

<tr>
<td>
Note 4<input type="radio" name="coolundwitzig" value="4">
</td>
</tr>

<tr>
<td>
Note 5<input type="radio" name="coolundwitzig" value="5">
</td>
</tr>

<tr>
<td>
Note 6<input type="radio" name="coolundwitzig" value="6">
</td>
</tr>

<input type="hidden" name="a" value="1">
<input type="hidden" name="b" value="2">

<tr>
<td>
<input type="submit" name="submit" value="submit">
</td>
</tr>

</table>

</form>

</html>

<?php

$a=sqlite_open('xy');
$submit=$_POST["submit"];
$coolundwitzig=$_POST["coolundwitzig"];
$hidden=$_POST["a"];

if (!$coolundwitzig)

{

}

else

{

sqlite_query($a, " update lehrerbenotung set coolundwitzig = coolundwitzig + $coolundwitzig where id='1'");
sqlite_query($a, " update lehrerbenotung set b = b + $hidden where id= '1'");

}

$b= sqlite_query($a, "select * from lehrerbenotung where id= '1' ");
while ($c= sqlite_fetch_array($b))

{

$gesamt=$c['coolundwitzig'];

$anzahl=$c['b'];

if (!$anzahl)

{

}

else

{

echo round($gesamt/$anzahl,3);

}

}

?>


Counter in PHP mit einfacher Textdatei als Datenbank

<?php
$filename = "counter.txt";
$datafile = fopen($filename , "r");
if ($datafile <=0)

{

}

else

{

$content = fgets($datafile, "12");
fclose($datafile);

}

++$content;
echo $content;

$datafile = fopen($filename , "w");
flock($datafile, "2");
fputs($datafile, $content );
flock($datafile, "3");
fclose($datafile);

?>


IP Datum Zeit speichern


tabelle.ip

<?php
include ('config.php');
$a= mysql_query("create table ip (id int (10) unsigned not null auto_increment,
ip text,
zeitdatum text,
primary key (id)
) type=myisam; ");

?>
 

ip.php

<?php
$a= $HTTP_SERVER_VARS["REMOTE_ADDR"];
$b=date('\D\a\t\u\m \u\n\d \U\h\r\z\e\i\t Y M d l H\:i\:s' );
include ('config.php');
$c = "insert into ip (ip, zeitdatum) values ('$a','$b')";
$d= mysql_query($c);

?>


ipanzeigen.php

<?php
include ('config.php');
$a= mysql_query("select * from ip ");
while ($b= mysql_fetch_row($a)) // while-Schleife

{

echo $b[0];
echo '<br>';
echo $b[1];
echo '<br>';
echo $b[2];
echo '<br>';
echo '<br>';

}

?>
 





zurück


Darstellung PHP5 MySQL SQLite

Valid HTML 4.01 Transitional