Re: Problems with a simple While-If condition
| From: | Jason Romero | Date: | Tue, 26 Nov 2002 23:00:36 +0000 |
| Subject: | Re: Problems with a simple While-If condition | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-126205@lists.php.net to get a copy of this message | ||
try using the extract command instead of the array reference
ie:
<?
while ($row = mysql_fetch_array($res)) {
extract($row);
echo"<tr><td>ID Profissional</td>";
echo"<td>$id</td></tr>";
?>
instead of :
while ($row = mysql_fetch_array($res)) {
?>
<?
echo"<tr><td>ID Profissional</td>";
echo"<td>".$row['id']."</td></tr>";
Jason
"Rodrigo De Oliveira" <thenewsource@ieg.com.br> wrote in message
news:002501c295a6$3e048ab0$6ed4a5c8@soho...
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");
?>