I am trying to create a member system in which you can view specific values from a database. It worked, so it’s great, but now I have a problem because I am using the NULL value for "age".
When viewing a profile page, it looks like this:
$id = $_GET["id"];
$result = mysql_query("SELECT * FROM membersfromsite WHERE `idofmember`=$_GET[id]");
$row = mysql_fetch_array($result);
echo "<b>" . $row['userusername'] . "</b>: </p>"; ?>
<?php
$id = $_GET["id"];
$result = mysql_query("SELECT * FROM membersfromsite WHERE `idofmember`=$_GET[id]");
$noage = mysql_query("SELECT ISNULL([age]) FROM membersfromsite WHERE `idofmember`=$_GET[id]");
while ($row = mysql_fetch_array($result))
{
echo "<p class='middle'>id-number: " . $row['idofmember'] . "<br>";
echo "Username: " . $row['userusername'] . "<br>";
if ($noage)
{
echo "Age not specified";
}
else
{
echo "Age: " .$row['age'] ;
}
}
I tried all sorts of other things, but the problem I am facing is that it either returns "Age not specified" on each user page, or age on each user page, including pages with a NULL value, which makes it look So:
Age:
The code you see above returns the age on each page, including pages with an age that is set to NULL. I do not understand if I change the code to this:
$noage = mysql_query("SELECT * FROM membersfromsite WHERE `idofmember`=$_GET[id] AND age IS NULL");
. IS NULL = NULL, , , , IF, "while", , , ...
, , , MyQS, $noage, , - , , .