![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
09/04/2008, 12:16
|
![Avatar de farra](http://static.forosdelweb.com/customavatars/avatar221260_2.gif) | | | Fecha de Ingreso: marzo-2008 Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 16 años, 11 meses Puntos: 20 | |
Re: pasar el valor de <option value=''> a base de datos Bue... despues de buscar mucho en google y buscarle la vuelta al fin lo logre...!!!!
gracias de todos modos...
Código:
<?php
function ExtraerEnTabla($envio){
$basura=htmlentities($envio);
$Reemplazar = array('<option value="','" >','</option>');
$Por = array("<tr><td>","</td><td>","</td></tr>");
$ResultadoNrodoc = str_replace($Reemplazar, $Por, $basura);
$listo=$ResultadoNrodoc;
return $listo;
}
function ExtraerEnSQL($envio,$bd,$tb,$c1,$c2){
$basura=htmlentities($envio);
$Reemplazar = array('<option value="','" >','</option>');
$Por = array("INSERT INTO `$bd`.`$tb` (`$c1`,`$c2`) VALUES ('","','","');<br />");
$ResultadoNrodoc = str_replace($Reemplazar, $Por, $basura);
$listo=$ResultadoNrodoc;
return $listo;
}
$listo=ExtraerEnTabla($_POST['basura']);
$listo2=ExtraerEnSQL($_POST['basura'],$_POST['bd'],$_POST['tb'],$_POST['c1'],$_POST['c2']);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Extractor de Valores de <option value=""></option></title>
<script>
function muestrasql(accion){
if(accion == "SI"){
document.getElementById('sql').style.display='';
}else{
document.getElementById('sql').style.display='none';
}
}
</script>
</head>
<body>
<div align="center"><form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<label>
<textarea name="basura" cols="50" rows="6" id="basura"><?php echo htmlentities($_POST['basura']); ?></textarea>
<br />
<br />
Formato:
<input type="radio" name="formato" id="formatotabla" value="tabla" <?php if (!isset($_POST['MM_remove'])){ ?>checked="checked"<?php } ?><?php if(isset($_POST['MM_remove']) && ($_POST['formato'] == "tabla")){ ?>checked="checked"<?php } ?> onclick="muestrasql('NO');" />
Tabla
<input type="radio" name="formato" id="formatosql" value="sql" <?php if(isset($_POST['MM_remove']) && ($_POST['formato'] == "sql")){ ?>checked="checked"<?php } ?> onclick="muestrasql('SI');" />
SQL
<br />
<?php
$none="none";
if(isset($_POST['MM_remove']) && ($_POST['formato'] == "sql")){
$none="";
}
?>
<div id="sql" style="display:<?php echo $none; ?>;"> Base de datos: </label>
<label>
<input name="bd" type="text" id="bd" value="<?php echo htmlentities($_POST['bd']); ?>" />
</label>
Tabla
<label>
<input name="tb" type="text" id="tb" value="<?php echo htmlentities($_POST['tb']); ?>" />
</label>
<br />Campo1
<label>
<input name="c1" type="text" id="c1" value="<?php echo htmlentities($_POST['c1']); ?>" />
</label>
Campo2
<label>
<input type="text" name="c2" id="c2" value="<?php echo htmlentities($_POST['c2']); ?>" />
</label>
<br /></div>
<br />
<label><input type="submit" name="button" id="button" value="Extraer Valores" />
</label>
<input type="hidden" name="MM_remove" id="MM_remove" value="form1" />
</form>
</div>
<hr />
<div align="center"><?php if(isset($_POST['MM_remove']) && ($_POST['formato'] == "tabla")){ ?><table border="1" width="400">
<tr><td bgcolor="#CCCCCC"><strong>Value=""</strong></td>
<td bgcolor="#CCCCCC"><strong>Option</strong></td>
</tr><?php echo $listo; ?></table><?php } ?>
<br /><br />
<?php if(isset($_POST['MM_remove']) && ($_POST['formato'] == "sql")){ ?>
<?php echo $listo2; ?>
<?php } ?>
</div>
</body>
</html>
|