0
echo "<td>" . "<input type=text name=name value=". $inventory['part_name']. " </td>";

When I print this, it only shows "air". However, what is stored inside the database is "air filter". What is the problem? It only prints until before the space. Is there any other way to show the text include after the space text? The above code is inside the PHP.

0

3 Answers 3

2

You're missing quotes around the html attributes, and the closing angle bracket for your input element.

Try this:

echo "<td><input type='text' name='name' value='". $inventory['part_name']. "'></td>";

Note this assumes you won't have a single quote in your $inventory['part_name'], might be good to escape that.

Sign up to request clarification or add additional context in comments.

Comments

0

As described by jszobody's answer, you have missed quotes and > before </td> tag.

Simply write:-

echo "<td><input type='text' name='name' value='{$inventory['part_name']}'></td>";

Hope it will help you :-)

Comments

0

The Best Way is that always separate HTML and PHP so that easily readable. you can do in following format. In this format error are reduce.

<td>
   <input type='text' name='name' value='<?php echo $inventory['part_name']; ?>'>
</td>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.