ihr kennt sicherlich alle diese "Schick den Link 5 mal weiter und du bekommst dies und das seiten...". Habe mir in den Kopf gesetzt selber mal versuchen ein "funktionierendes" php script auf die Beine zu stellen. Ich bin in php nicht sonderlich geübt also hat mein kumpel schon mal etwas für mich auf die beine gestellt:
seite1.php
PHP-Code:
<?php
if (isset($_GET['id']))
{
$id = $_GET['id'];
include("connect.php");
$sql = "SELECT id, count FROM test WHERE id LIKE '$id' LIMIT 1";
$result = mysql_query($sql);
$num = mysql_num_rows($result);
if ( $num < 1 )
{
$i = 1;
$to_add = "INSERT INTO test (id, count) VALUES ('$id', '$i')";
$add = mysql_query($to_add) or die ("Fehler!");
}
elseif ( $num > 1)
{
while($row = mysql_fetch_object($result))
{
$row->count = $i;
$i = $row->count;
$i++;
$edit = "UPDATE test set count = '$i' WHERE id = '$id'";
$update = mysql_query($edit);
}
}
}
?>
<html>
hier gehts weiter:
<a href="seite2.php">Seite2.php</a>
</html>
PHP-Code:
<html>
Ihr link ist:
</html>
<?php
$id = 123; #Hier liegt u.a mein problem
include("connect.php");
$sql = "SELECT id, count FROM test WHERE id LIKE '$id' LIMIT 1";
$result = mysql_query($sql);
while($row = mysql_fetch_object($result))
{
echo "Bisher haben";
echo $row->count;
echo "Leute auf ihren Link geklickt";
}
?>
</html>
mfg.wanx
