noob nic question
Posted: Tue Jul 12, 2005 2:49 pm
Hi everyone, to begin with, im french
anyway I have a prob with some newbie code, since im noob it's normal...
The thing is than i don't understand, why in the following code (isset($start)) alway return false...
I have read isset in php.net but without any succes... thank for helping me.
d11wtq | Please use
The thing is than i don't understand, why in the following code (isset($start)) alway return false...
I have read isset in php.net but without any succes... thank for helping me.
Code: Select all
<?php
if (isset($start))
{
$start=$_GET["start"];
$query = "SELECT * FROM inscription LIMIT " . $start . ", 1";
@mysql_connect("localhost","root","") or die("Echec de connexion au serveur.");
@mysql_select_db("form") or die("Echec de seclection de la base.");
$result = mysql_query($query); //you should do error checking
//display data
while ($ligne = mysql_fetch_row($result))
{
echo "<BR>";
/* foreach() passe en revue toutes les valeurs d'un tableau. */
foreach ($ligne as $value) echo "$value <BR>";
}
echo "<br />";
//this code was wrong, I did not have the second query. Thanks to Plaggy Pig.
// need another query to get the total amount of rows in our table
$query = "SELECT count(*) as count FROM inscription";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if($start > 0)
echo "<a href=\"" . "erreur.php" . "?start=" . ($start - 1) . "\">Previous</a> \ ";
if($numrows > ($start + 1))
echo "<a href=\"" . "erreur.php" . "?start=" . ($start + 1) . "\">Next</a><BR>";
}
else
{
echo "var pas seter";
$start=0;
$query = "SELECT * FROM inscription LIMIT " . $start . ", 1";
@mysql_connect("localhost","root","") or die("Echec de connexion au serveur.");
@mysql_select_db("form") or die("Echec de seclection de la base.");
$result = mysql_query($query); //you should do error checking
//display data
while ($ligne = mysql_fetch_row($result))
{
echo "<BR>";
/* foreach() passe en revue toutes les valeurs d'un tableau. */
foreach ($ligne as $value) echo "$value <BR>";
}
echo "<br />";
//this code was wrong, I did not have the second query. Thanks to Plaggy Pig.
// need another query to get the total amount of rows in our table
$query = "SELECT count(*) as count FROM inscription";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if($start > 0)
echo "<a href=\"" . "erreur.php" . "?start=" . ($start - 1) . "\">Previous</a> \ ";
if($numrows > ($start + 1))
echo "<a href=\"" . "erreur.php" . "?start=" . ($start + 1) . "\">Next</a><BR>";
}
?>Code: Select all
tags when posting PHP code [/color]