Page 1 of 1

input text

Posted: Fri Mar 28, 2003 7:02 am
by taboas
In following script I modify the data of the table “Memorias”
The problem consists of which in the instruction (<input type….)
single it shows the first word of the fields
where it is the error?

mysql_select_db('auth',$conexion);
$result=mysql_db_query("auth","select * from Memorias where Numero='$numero'");
$row = mysql_fetch_row($result);
echo "<td> Número de Memoria:&nbsp;&nbsp; $numero</td><tr>";
echo "<td> Nombre:&nbsp;&nbsp; <input type=text name='nombre' value=$row[1]></td><tr>";
echo "<td> Teléfono:&nbsp;&nbsp;<input type=text name='telefono' value=$row[2]></td><tr>";
echo "<td> Mail:&nbsp;&nbsp;<input type=text name='email' value=$row[3]></td><tr>";
echo "<td> <input type=hidden name='numero' value=$row[0]>";
echo "<input type=submit value='Modificar los datos'></td></tr>";
echo "</table>";

Posted: Fri Mar 28, 2003 9:37 am
by haagen
You need to use " or ' in when feeding your values, like:


<input type=text name=myname value="<?= $row[0] ?>">

Hope this helps!

Posted: Sat Mar 29, 2003 4:25 am
by DocSeuss
echo "<td> Nombre: <input type=text name='nombre' value='$row[1]'></td><tr>";


will work just surrond your variable with ' ' like '$row[1]'
this is assuming you keep it in an echo statement.

Posted: Sat Mar 29, 2003 7:01 am
by twigletmac
Don't use single quotes to surround HTML attributes, it's not standard and it's not neccessary because you can do:

Code: Select all

echo "<td> Nombre: <input type="text" name="nombre" value="$row[1]"></td><tr>";
or

Code: Select all

echo '<td> Nombre: <input type="text" name="nombre" value="'.$row[1].'"></td><tr>';
Also quoting all your HTML attributes will solve the problem of only one word getting passed because if you have this:

Code: Select all

&lt;input type="text" name="test" value=just testing&gt;
the browser has no way of knowing that testing is part of the value attribute whereas it does if you have this:

Code: Select all

&lt;input type="text" name="test" value="just testing"&gt;
Mac