Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/12/2003, 14:28
blackseba
 
Fecha de Ingreso: diciembre-2002
Ubicación: Santiago de Chile
Mensajes: 350
Antigüedad: 21 años, 4 meses
Puntos: 0
Insertar el "value" de una "option" en un "Select" en MySQL

Nuevamente tengo un problema
No se como insertar el valor del "value" en una option de un select en MySQL

Mi código es el siguiente:

Código PHP:
<?
include("conexio.php");

echo 
"<table width=500 align=center bgcolor=white cellspacing=1 cellpadding=3>
<tr><td><font face=Tahoma size=2><a href=agregar_cat.php>
<b>AGREGAR CATEGORIA</></b></td><font face=Tahoma size=2>
<a href=add_chiste.php><b>AGREGAR CHISTE</a></b></td></tr></table>"
;

if(
$accion=="listo"){
mysql_query("INSERT INTO chistes (id_cat,autor,chiste) VALUES ('$id_cat_chiste','$autor','$chiste')",$conexio);

$idmysql_insert_id();

echo 
"<center><font face=Tahoma size=2><b>Chiste agregado con exito!!</b><br>
<font face=Tahoma color=red size=2>Chiste numero $id</font><br><br>
<a href=\"add_chiste.php\">Regresar</a></center>"
;

} else {


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=categoria>";
while (
$row=mysql_fetch_array($result)) {
$id_cat_chiste $row["id"];
$categos $row["categoria"];

echo 
"<option value=$id_cat_chiste>$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>"
;

}


?>

Esta es mi estructura de la BD:

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)
)

Lo raro es que en mysql si se agrega $categos pero no el id que corresponde que se supone debe tomarla de la tablar cat_chistes
__________________
Animacion de cumpleaños