Problems with a simple While-If condition
| From: | Rodrigo de Oliveira | Date: | Tue, 26 Nov 2002 23:47:49 +0000 |
| Subject: | Problems with a simple While-If condition | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-126196@lists.php.net to get a copy of this message | ||
This is the fact:
I'm building a homepage that can access a mysql database, and display the records within a
certain condition. Following this it is verified if the sql result was empty then it should write a
certain frase, if not it should write the records. I've got the worst part ok, the while that
display the results, but the if isn't being verified, it writes the frase anyway.
Please help, the code is right under the file name:
indicador.php
<?
include "db_dados.php";
?>
<? $sql = "SELECT * FROM tb_tao WHERE area='$area'and status=1";
$res = @mysql_query($sql,$id)
?>
<?
echo "<table width='100%' height='100%' border='0'
align='center'>"
?>
<?
echo "<tr><td><div align='center'>Nenhum profissional
cadastrado.</div></td></tr>";
?>
<?
while ($row = mysql_fetch_array($res)) {
?>
<?
echo"<tr><td>ID Profissional</td>";
echo"<td>".$row['id']."</td></tr>";
echo"<tr><td>Nome</td>";
echo"<td>".$row['nome']."</td></tr>";
echo"<tr><td>Profissão</td>";
echo"<td>".$row['area']."</td></tr>";
echo"<tr><td>Bairro</td>";
echo"<td>".$row['bairro']."</td></tr>";
echo"<tr><td>Telefone</td>";
echo"<td>".$row['telefone']."</td></tr>";
echo"<tr><td>E-mail</td>";
echo"<td>".$row['email']."</td></tr>";
echo"<tr><td>Telefone Celular</td>";
echo"<td>".$row['celular']."</td></tr>";
echo"<tr><td>Registro Profissional</td>";
echo"<td>".$row['regprof']."</td></tr>";
echo"<tr><td>Endereço</td>";
echo"<td>".$row['endereco']."</td></tr>";
echo"<tr><td> </td>";
echo"<td> </td></tr>";
?>
<?
}
?>
<?
echo"</table>";
?>
db_dados.php
<?
$id = mysql_connect("localhost","rodrigo","g3mston3")or die ('I
cannot connect to the database.');
$con = mysql_select_db("db_tao");
?>