input text

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
taboas
Forum Newbie
Posts: 4
Joined: Tue Mar 18, 2003 1:50 pm

input text

Post 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>";
User avatar
haagen
Forum Commoner
Posts: 79
Joined: Thu Jul 11, 2002 3:57 pm
Location: Sweden, Lund

Post by haagen »

You need to use " or ' in when feeding your values, like:


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

Hope this helps!
DocSeuss
Forum Newbie
Posts: 10
Joined: Sat Mar 29, 2003 3:28 am

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply