Jump to content

Recommended Posts

Posted (edited)

Boas pessoal, estou a tentar listar dados das colunas "category" (category,category_en), mas pelos vistos não consigo listar os dados da category_en, alguem sabe qual poderá ser o problema?

<?php
$qry=mysql_query("SELECT * FROM category", $con);
if(!$qry)
{
die("Query Failed: ". mysql_error());
}
?>
<tr valign="baseline">
	 <td nowrap align="right" valign="top"> </td>
	 <td>Categoria Produto</td>
	 </tr>
	 <tr valign="baseline">
	 <td nowrap align="right" valign="top"> </td>
	 <td><select name="category" id="category">
<?php
while($row=mysql_fetch_array($qry))
{
echo "<option value='".$row['category']."'>".$row['category']."</option>";

}
?>
</select>
</td>
	 </tr>
	 <tr valign="baseline">
	 <td nowrap align="right" valign="top"> </td>
	 <td>Categoria Produto Ingles</td>
	 </tr>
	 <tr valign="baseline">
	 <td nowrap align="right" valign="top"> </td>
	 <td><select name="category_en" id="category_en">
<?php

while($row=mysql_fetch_array($qry))
{

echo "<option value='".$row['category_en']."'>".$row['category_en']."</option>";

}
?>
</select>
Edited by bonucci
Posted

CREATE TABLE IF NOT EXISTS `category` (

`category` varchar(200) NOT NULL,

`category_en` varchar(200) NOT NULL,

PRIMARY KEY (`category`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Não me perguntem porque está assim, estranhei porque não aparece o id, mas foi assim que me foi dado.

Posted

antes do segundo while coloca esta linha:

mysql_data_seek($qry, 0);

podes ver aqui porquê : http://pt1.php.net/manual/en/function.mysql-data-seek.php

também pode ver nessa página que o conjunto de funções mysql_* não deverá ser utilizado, aconcelhando passar a usar alternativas mais versáteis e seguras.

IRC : sim, é algo que ainda existe >> #p@p

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.