Answer the question
In order to leave comments, you need to log in
How to do empty field validation in mysql php table?
It is necessary to validate a certain field. If the field does not contain anything, then show the inscription "not found", and if there is, then vice versa "found"
I tried using mysql_num_rows, the code does not work:
if($_GET['do'] == 'catalog' && isset($_GET['company'])){
$id = intval($_GET['company']);
$query = "SELECT * FROM organizations WHERE `id` = '".$id."'";
$res = mysql_query($query);
if(mysql_num_rows($res) > null) {
echo "найден";
} else {echo 'не найден';}
Answer the question
In order to leave comments, you need to log in
if ($_GET['do'] == 'catalog' and isset ($_GET['company'])) {
$id = (int) $_GET['company'];
$query = "SELECT * FROM `organizations` WHERE `id` = '".$id."' LIMIT 10";
$res = mysqli_query ($query);
while ($row = mysqli_fetch_assoc ($res)) {
if (!$row['site'])
echo 'Нет';
else
echo 'Есть';
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question