Free Web Hosting Forum
Go Back   Free Web Hosting Forum > 000WebHost Services > Spanish Forum
Reload this Page modificar datos de sql desde html
Reply
 
Thread Tools Display Modes
(#1 (permalink))
Old
Junior Member
yedeon is on a distinguished road
 
Posts: 28
Join Date: Apr 2012
Default modificar datos de sql desde html - 05-06-2012, 04:38 PM

***********

Last edited by yedeon; 05-07-2012 at 04:39 PM.
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
Member
MAMM is on a distinguished road
 
Posts: 41
Join Date: Feb 2012
Default 05-06-2012, 05:04 PM

Quote:
Originally Posted by yedeon View Post
<HTML>
<HEAD>
<TITLE>19pruebas2.html</TITLE>
</HEAD>
<BODY>
<div align="center">
<h1>Actualizar un registro</h1>
<br>
<?
mysql_connect("****");
mysql_select_db("****");
echo '<FORM METHOD="POST" ACTION="19actualizar2.php">nombre<br>';
$sSQL="Select nombre From orejas Order By nombre";
$result=mysql_query($sSQL);
echo '<select nombre="nombre">';
//Generamos el menu desplegable
while ($row=mysql_fetch_array($result))
{echo '<option>'.$row["nombre"];}
?>
</select>
<br>
nombre<br>
<INPUT TYPE="TEXT" NAME="nombre"><br>
<INPUT TYPE="SUBMIT" value="Actualizar">
</FORM>
</div>
</BODY>
</HTML>
-------------------------------
<HTML>
<HEAD>
<TITLE>19actualizar2.php</TITLE>
</HEAD>
<BODY>
<?
mysql_connect("***");
mysql_select_db("***");
$sSQL="Update orejas Set tel='$nombre' Where nombre='$nombre'";
mysql_query($sSQL);
?>
<h1><div align="center">Registro Actualizado</div></h1>
<div align="center"><a href="minsertar3.php">Visualizar el contenido de la base</a></div>
</BODY>
</HTML>
Si mis ojos no me engañan, esas líneas son las únicas erroneas.

Primera línea:

nombre="nombre"? Ahí tienes que colocar name="nombre" para que asigne el nombre correctamente de la función html.

Segunda línea:

Te explico algo que espero te sea para un futuro.

La diferencia entre comillas dobles y comillas simples es que las comillas simples no interpretan variables por su valor, las comillas dobles sí.

Por ejemplo:

PHP Code:
$variable 1;

echo 
'Esto es igual a $variable'// Encerrado por comillas simples.
ResultadoEsto es igual a $variable

echo "Esto es igual a $variable"//Encerrado por comillas dobles.
ResultadoEsto es igual a 1 
Es algo tan mínimo pero de gran importancia, para que una variable te funcione con comillas simples tendrías que cerrar la comilla, agregar php, abrir comilla y seguir con el echo.

Ejemplo:
PHP Code:
echo 'Esto es igual a '.$variable
Es lo único erroneo que he encontrado, si miro algo más o que te falta te lo hago saber.

Saludos!
Reply With Quote
(#3 (permalink))
Old
Junior Member
yedeon is on a distinguished road
 
Posts: 28
Join Date: Apr 2012
Default 05-06-2012, 05:44 PM

-----------------------------------------

Last edited by yedeon; 05-08-2012 at 07:18 PM.
Reply With Quote
(#4 (permalink))
Old
Member
MAMM is on a distinguished road
 
Posts: 41
Join Date: Feb 2012
Default 05-06-2012, 05:49 PM

Hola yedeon,

Me he equivocado, me he confundido así como tienes la variable está correctamente, es que como ando en el trabajo veo muy rápido XD. Deja esa línea tal y como está. Al menos que te sirva la explicación de las comillas xDDD.

Dame unos minutos a ver si encuentro un problema del porqué no te funciona, que poco puedo mirar ahora con detalle.

Saludos!
Reply With Quote
(#5 (permalink))
Old
Junior Member
yedeon is on a distinguished road
 
Posts: 28
Join Date: Apr 2012
Default 05-06-2012, 06:38 PM

-----------------------------------

Last edited by yedeon; 05-08-2012 at 07:18 PM.
Reply With Quote
(#6 (permalink))
Old
Member
MAMM is on a distinguished road
 
Posts: 41
Join Date: Feb 2012
Default 05-06-2012, 06:59 PM

Hola yedeon,

Dime una cosa, ¿qué objetivo quieres llegar con el código?, así veo mejor y si es posible creo un código yo mismo para darte de ejemplo y explicarte con detalle para que funciona cada cosa.

Saludos!

Last edited by MAMM; 05-06-2012 at 07:02 PM.
Reply With Quote
(#7 (permalink))
Old
Junior Member
yedeon is on a distinguished road
 
Posts: 28
Join Date: Apr 2012
Default 05-06-2012, 07:06 PM

-----------------------

Last edited by yedeon; 05-08-2012 at 07:18 PM.
Reply With Quote
(#8 (permalink))
Old
Junior Member
yedeon is on a distinguished road
 
Posts: 28
Join Date: Apr 2012
Default recoger checkbox de html a sql mediante php - 05-07-2012, 04:38 PM

como pasar el valor de un campo de texto "nombre" en paginaA , a campo de texto "nombre" en paginaB ?

tengo el codigo de pagina A
<html>
<head><title>paginaA</title></head>
<body>
<form action="paginaB.html" method="post">
nombre <input type="text" name="nombre" id="nombre"><br>
<input name="Enviar" Type="submit" value="Enviar"><br>
</form>
</body>
</html>

pero ni idea de que poner en paginaB para que el campo de texto "nombre" sea igual al de paginaA ?

alguna idea , ? muchas gracias , buen inicio de semana

Last edited by yedeon; 05-08-2012 at 07:19 PM.
Reply With Quote
(#9 (permalink))
Old
Junior Member
yedeon is on a distinguished road
 
Posts: 28
Join Date: Apr 2012
Default como pasar lo seleccionado a base de datos sql con php - 05-09-2012, 12:23 AM

tengo este codigo que me da opciones de elegir
como paso lo escogido a my base de datos ?

al realizar submit en pagina html me aparece la url
....w w w .mipagina/insertar5.html?firstChoice=2&secondChoice=5&thirdC hoice=5&ciudad=A&firstchoice=B[/url]

intente con get para conseguir los valores de url pero no me funciona

----------------------------insertar5.html-----------------------------------------
<html>
<TITLE>insertar5.html</TITLE>
<title>Listas desplegables dependientes</title>
<BODY style="font-family: Verdana">
<p align="center"><b>Listas desplegables dependientes 5</b></p>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var arrItems1 = new Array();
var arrItemsGrp1 = new Array();

arrItems1[1] = "a1"; arrItemsGrp1[1] = 1;
arrItems1[2] = "a2"; arrItemsGrp1[2] = 1;
arrItems1[3] = "a3"; arrItemsGrp1[3] = 1;
arrItems1[4] = "a4"; arrItemsGrp1[4] = 1;
arrItems1[5] = "b1"; arrItemsGrp1[5] = 2;
arrItems1[6] = "b2"; arrItemsGrp1[6] = 2;
arrItems1[7] = "c1"; arrItemsGrp1[7] = 3;
arrItems1[8] = "c2"; arrItemsGrp1[8] = 3;

var arrItems2 = new Array();
var arrItemsGrp2 = new Array();

arrItems2[1] = "aa1"; arrItemsGrp2[1] = 1;
arrItems2[2] = "aa2"; arrItemsGrp2[2] = 2;
arrItems2[3] = "aa3"; arrItemsGrp2[3] = 3;
arrItems2[4] = "aa4"; arrItemsGrp2[4] = 4;
arrItems2[5] = "bb1.1"; arrItemsGrp2[5] = 5;
arrItems2[6] = "bb1.2"; arrItemsGrp2[6] = 5;
arrItems2[7] = "bb2.1"; arrItemsGrp2[7] = 6;
arrItems2[8] = "cc1.1"; arrItemsGrp2[8] = 7;
arrItems2[9] = "cc1.2"; arrItemsGrp2[9] = 7;
arrItems2[10] = "cc2.1"; arrItemsGrp2[10] = 8;
arrItems2[11] = "cc3.1"; arrItemsGrp2[11] = 9;


function selectChange(control, controlToPopulate, ItemArray, GroupArray)
{
var myEle ;
var x ;
// Empty the second drop down box of any choices
for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;
if (control.name == "firstChoice") {

// Empty the third drop down box of any choices
for (var q=myChoices.thirdChoice.options.length;q>=0;q--) myChoices.thirdChoice.options[q] = null; }

// ADD Default Choice - in case there are no values
myEle = document.createElement("option") ;
myEle.value = 0 ;
myEle.text = "[Selecciona]" ;
controlToPopulate.add(myEle) ;

// Now loop through the array of individual items
// Any containing the same child id are added to
// the second dropdown box
for ( x = 0 ; x < ItemArray.length ; x++ )
{
if ( GroupArray[x] == control.value )
{
myEle = document.createElement("option") ;
myEle.value = x ;
myEle.text = ItemArray[x] ;
controlToPopulate.add(myEle) ;
}
}
}
// End -->
</script>

</HEAD>
<BODY style="font-family: Verdana">
<form name=myChoices>
<table align="center">
<tr>
<td>

<SELECT id=firstChoice name="firstChoice" onchange="selectChange(this, myChoices.secondChoice,

arrItems1,arrItemsGrp1);">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
</select> </br>


</SELECT>
</TD><TD>
<SELECT id=secondChoice name=secondChoice onchange="selectChange(this, myChoices.thirdChoice, arrItems2,

arrItemsGrp2);">
</SELECT>
<SELECT id=thirdChoice name=thirdChoice>
</SELECT>
</TD>
</TR>
<FORM METHOD="POST" ACTION="insertar5.php">
<INPUT TYPE="SUBMIT" value="insertar5">
</TABLE>
</html>
----------------------insertar5.php--------------------------------------------

<?
$con = mysql_connect("**********");
mysql_select_db("*********", $con);
if (!$con) { die('Could not connect: ' . mysql_error()); }
$sql="INSERT INTO orejas (firstchoice,secondChoice,thirdChoice)
VALUES('$_POST[firstchoice]','$_POST[secondChoice]','$_POST[thirdChoice]')";
if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); }echo "1 record added";
mysql_close($con);
?>


--------------------------------------------------------------------------------

help sos , Muchas gracias , saludos a todos
Reply With Quote
(#10 (permalink))
Old
d3iti's Avatar
Super Moderator
d3iti is on a distinguished road
 
Posts: 6,528
Join Date: Jul 2009
Location: Spain
Default 05-09-2012, 06:49 AM

Hola yedeon

Creo que desconoces el funcionamiento básico de un foro. En un foro se pregunta para que si hay otros usuarios con el mismo problema puedan usar las respuestas que de forma gratuita y voluntaria le han dado en el foro.

Si sigues borrando/modificando y cambiando "-----------------" el contenido de tus mensaje me veré obligado a banearte por no entender cual es el funcionamiento de un foro. No puedes pretender obtener ayuda sin dejar que otros puedan hacer uso de esta ayuda.


Recuerda realizar copias de seguridad de tus sitios web. Si este mensaje te ayudó puedes pulsar sobre el botón karma
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com