Page 1 of 1

mysql_fetch_row problem

Posted: Wed Jul 09, 2003 4:55 pm
by sulen
I am using the mysql_fetch_row to obtain the results from a select query to a Mysql database and populate the text fields of a given form using the values generated. The values are retrieved perfectly by the select but the following problem occurs when the values popluate the text fields

eg if if I have an entry "web programmer" in the table, the text field is only polpulated by the first word before the space that is "web" and programmer disappears.

So basically everything after the space is being truncated on dispaly in the text box.

Kindly let me know what the error could be.

Thanks

Sulen

Posted: Wed Jul 09, 2003 6:01 pm
by trollll
That sounds rather odd. Can you post the code that you use from getting it out of the DB to actually writing it into the text field? That would probably help to see exactly what you have going on throughout the process.

the code for mysql_fetch_row problem

Posted: Wed Jul 09, 2003 6:18 pm
by sulen
This is the code that I am using to perform the required functions spoken about.

mysql_select_db("altura");

$sql = "select * from directory where pno like '%".$pno."%'";

$result = mysql_query($sql);
//$num_results = mysql_num_rows($result);

//for($i=0; $i <$num_results; $i++)

while($i = mysql_fetch_row($result))
{
echo $i[3];?>
<form action='uconfirm.php' method='post'>
<p>Update Employee Information</p>
<p> Last Name
<input type=text size=40 name=lname value=<?=$i[0]?>>
<br><BR>
First Name
<input type=text size=40 name=fname value=<?=$i[1]?>>
<br><BR>
Branch
<input type=text size=40 name=region value=<?=$i[2]?>>
<br><BR>
Title
<input type=text size=40 value=<?=$i[3]?>>
<br><BR>
<input type=submit value=Update></p></form></body>
</html>
<?
}
?>

Posted: Wed Jul 09, 2003 8:32 pm
by trollll
You need to enclose the html attribute in quotes. If you don't, it will think that the next word in the attribute value actually counts as the next attribute.

Ex.

Code: Select all

<input type="text" size="40" name="title" value="Two Words" />

rather than

<input type=text size=40 name=title value=Two Words />
You may want to check out w3school's xhtml section for some good coding practices. Even if you just apply some principles to your html it should help a bit.