I want something strange. If someone opens index.php page, $select must be full, . But if someone opens index.php?var=4 page, $select must be other, with var from _GET.
I have this code now, but it works only if ?var=3 exists.
What am I missing?
foreach($_GET as $name=>$value)
{
if($name == 'lvl') {
$value = mysql_real_escape_string($_GET[lvl]);
$select = mysql_query("SELECT * from $table where lvl='$value'");
}
else {
$select = mysql_query("SELECT name,image,lvl,team,icon FROM $table");
}
}
while ($row = mysql_fetch_array($select))
{
$name = mysql_real_escape_string($row['name']);
You are depending on the existence of a
?lvl=...in your code.Also, using the mysql-functions is not recommended, since they are deprecated. Consider changing to mysqli or PDO. For this example, I’ll still use mysql-functions.
Better to use this: