So I want to be able to use a WHERE command in SQL to select certain values from a table. This is my current code however it doesn't work
$MobileNumber = $_GET["MobileNumber"];
$TeamGroup = $_GET["TeamGroup"];
if($_REQUEST=['MobileNumber']) {
$Item = "SELECT a,b,c,d FROM Item WHERE MobileNumber = $MobileNumber";
} elseif($_REQUEST=['TeamGroup']) {
$Item = "SELECT a,b,c,d FROM Item WHERE TeamGroup = $TeamGroup";
} else {
$Item = "SELECT a,b,c,d FROM Item";
};
$result = mysql_query($Item) or die ("Error in query: $query. ".mysql_error());
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
print '<table><tr>';
foreach($row as $name => $value) {
print "<th>$name</th>";
}
print '</tr>';
while($row) {
print '<tr>';
foreach($row as $value) {
print "<td>$value</td>";
}
print '</tr>';
$row = mysql_fetch_assoc($result);
}
print '</table>';
} else {
echo "No Items Assigned";
};
It works for when the url is test.php?MobileNumber=...
but not when its has TeamGroup or nothing in the url. The url I have is like this: test.php?TeamGroup=11
EDIT: Added more code to let you see what I am trying to display