Jump to content
JFernandesVR

[Resolvido] List/menu com php mysql

Recommended Posts

JFernandesVR

Boas pessoal.

como posso criar um list/menu em php com ligação a base de dados?

fiz o seguinte e nao ta a funcionar

<select name="categoria">
<?php
mysql_connect("localhost","*******","********") or die ("Impossivel ligar a base de dados");
$sql=mysql_query("SELECT * FROM galeriacat");
$resultado=mysql_db_query("********",$sql);
while ($dados=mysql_fetch_array($resultado))
{
?>
<option value='".$dados['categoria']."'><?php echo $dados['categoria'] ?></option>
<?php
}
?>
</select>

Edited by JFernandesVR

Share this post


Link to post
Share on other sites
JFernandesVR

fiz outra vez

aqui vai o codigo

<select name="select" id="ddlcategoria">
  <option id="0">-- Seleccione a categoria--</option>
<?php
mysql_connect("localhost","******","*******") or die ("Impossivel ligar a base de dados");
$getallcat = mysql_query("SELECT * FROM galeriacat");
while($viewallcat = mysql_fetch_array($getallcat))
{
?>
  <option id="<?php echo $viewallcat['id']; ?>"><?php echo $viewallcat['categoria']; ?></option>
<?php }?>
</select>

continua a nao funcionar

da erro nesta linha

while($viewallcat = mysql_fetch_array($getallcat)){

mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/realoff/public_html/Admin2.php on line 1187

Edited by JFernandesVR

Share this post


Link to post
Share on other sites
NunoDinis

a tabela galeriacat existe ??


Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro.

ndsotware.org

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.