Tengo el siguiente problema ahora
Lo que pasa es que no me ingresa un dato que el la id de la categoria en la id_cat del chiste. La estructura es la siguiente:
CREATE TABLE cat_chistes (
id int(9) NOT NULL auto_increment,
categoria char(255) NOT NULL,
PRIMARY KEY (id)
)
CREATE TABLE chistes (
id int(9) NOT NULL auto_increment,
id_cat char(255) NOT NULL,
autor char(255) NOT NULL,
chiste longtext NOT NULL,
PRIMARY KEY (id)
)
Para agregar el chiste mas o menos esta es la instruccion:
Código PHP:
mysql_query("INSERT INTO chistes (id_cat,autor,chiste) VALUES ('$aydi','$autor','$chiste')",$conexio);
Pero el problema es que para poder insertar id_cat o la variable $aydi el formulario en la lista debe poner el valor "name" de acuerdo a la "id" que tenga la <option>
No se si me explico bien
Esto es más o menos el formulario:
Código PHP:
echo "
<form method=post action=\"add_chiste.php?accion=listo\">
<b><font face=Tahoma size=2>
ID CATEG";
$result=mysql_query("select * from cat_chistes", $conexio)or die (mysql_error());
echo "<select name=$aydi>";
while ($row=mysql_fetch_array($result)) {
$aydi = $row["id"];
$categos = $row["categoria"];
echo "<option>$categos</option>";
}
echo "</select>
Autor <input type=text name=autor><br>
Chiste <textarea name=chiste rows=10 cols=60></textarea><br>
<input type=submit name=enviar value=enviar>";
Por favor necesito ayuda