0

While displaying the data from the database on a text box, I can access only the first part of the name. For example, if the name is 'Five Star', only the name 'Five' is displayed. Can you help in this? I'm just a beginner.
This is the code i've used echo "<tr><td>Reg.No.:</td><td width='200'><input type='text' name='reg' value=".$row[RegNo]."></td></tr>";

9
Contributors
19
Replies
38
Views
5 Years
Discussion Span
Last Post by Persi
Featured Replies
  • Hello, please check below code: <?php $reg=$row[RegNo]; echo "<tr><td>Reg.No.:</td><td width='200'><input type='text' name='reg' value='$reg'></td></tr>"; ?> Read More

  • 1

    If the value attribute is used without quotes, then the space (after Five in your case) will be assumed as the separator for the next attribute. [CODE=html] <!-- this was your output --> <input type='text' name='reg' value=Five Stars /> <!-- this is what it should be (as amitengg showed) --> … Read More

  • 1
    diafol 3,720   5 Years Ago

    Are you using php to output the whole html? either [CODE]<input type="text" name="name" value="<?php echo $row['name']; ?>"><br/>[/CODE] OR [CODE]echo "<input type=\"text\" name=\"name\" value=\"{$row['name']}\"><br/>";[/CODE] Read More

0

Names need to be single words. No spaces. When you say 'name', I'm assuming you mean the name attribute. If not, what do you mean?

Edited by diafol: n/a

1

Hello,
please check below code:

<?php
$reg=$row[RegNo];

echo "<tr><td>Reg.No.:</td><td width='200'><input type='text' name='reg' value='$reg'></td></tr>";
?>

1

If the value attribute is used without quotes, then the space (after Five in your case) will be assumed as the separator for the next attribute.

<!-- this was your output -->
<input type='text' name='reg' value=Five Stars />

<!-- this is what it should be (as amitengg showed) -->
<input type='text' name='reg' value='Five Stars' />

Edited by pritaeas: n/a

Votes + Comments
Ah! Now I get it. Yes, agree.
0

How does the text look like in the database? Five Star? or Five_Star?

It is Five Star. Din't use any underscore.

0

Names need to be single words. No spaces. When you say 'name', I'm assuming you mean the name attribute. If not, what do you mean?

Why can't I use two words? Is there any way I can do this?
<input type="text" name="name" value=<?php echo $name; ?>><br/> hear it is the php code but i can't access full name it only print the first part of the name can u help me pls? but i can access full name from $name in outside the input label

Edited by Persi: n/a

0

Sorry I misread your first post. Your value attribute can pretty much be anything

0

If the value attribute is used without quotes, then the space (after Five in your case) will be assumed as the separator for the next attribute.

<!-- this was your output -->
<input type='text' name='reg' value=Five Stars />

<!-- this is what it should be (as amitengg showed) -->
<input type='text' name='reg' value='Five Stars' />

I've used quotes for the value attribute. But it is the same.

0

You haven't added the quotes yet:

<input type="text" name="name" value="<?php echo $name; ?>"><br/>

Student Name:<input type='text' name='name' value=".$row.">"

0
$name = end(explode(" ", $row['name']));  // Star
$name = explode(" ", $row['name']));  // Five
1

Are you using php to output the whole html?

either

<input type="text" name="name" value="<?php echo $row['name']; ?>"><br/>

OR

echo "<input type=\"text\" name=\"name\" value=\"{$row['name']}\"><br/>";
-1

Post full code or a block of your code that contains the above line.

echo "<tr><td>Student Name:</td><td width='200'><input type='text' name='name' value=".$row."></td></tr>";

0

echo "<tr><td>Student Name:</td><td width='200'><input type='text' name='name' value=".$row."></td></tr>";

Thank u so much everyone. I got the solution.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.