0

Image

Hey guys, I have a problem here. As you see in this image, every time I echo the id related to the subject ID, the input value text will always align to the center.

How can I make it alignment to left?

I have use text-align: left in most cases , putting it to div, form, input.

Nothing works. Any solution for this?

Here's an example of my code:

<input class="form-control" placeholder="Subject ID" name="subId" type="text" style="width: 300px; padding:0px; text-align:left;" value="
<?php 
$sql = "SELECT subjectId FROM subjects WHERE id = $id";
$result = $conn->query($sql);
while ($row = $result->fetch_assoc()) {
echo $row['subjectId'];
}?>">

EDITED: Modify Page

Modify Page 2

As you can see from the Modify Page, when I want to modify a content let's say to modify Subject ID and Subject Name. I pressed Modify and it will href to id=1 and the next page Modify Page 2 will get the id by using GET method.

However, the text input value of the <input> does not align to the left for user friendly purposes. How can i make it align to the left once I clicked the modify button?

I echoed the value of the id and name inside the input value

Oliver Sim
  • 19
  • 7
  • Please go read [ask] and [mcve], and then edit your question accordingly. – misorude Nov 13 '18 at 15:32
  • What is the problem for my question – Oliver Sim Nov 13 '18 at 15:36
  • This code snippet does not make your problem reproducible, as you can see here: https://jsfiddle.net/1od0yfsq/ (just replaced the PHP parts with a static content for the value attribute there.) So, again: Please provide a _verifiable_ example. – misorude Nov 13 '18 at 15:37
  • Noted. Edited. Hold on let me try to find a php page validator – Oliver Sim Nov 13 '18 at 15:49
  • Do you really need the while loop? You're trying to get just one result, right? What css framework are you using, Bootstrap? You may have to use text-left class on the input and/or its parent
    element. Don't know exactly. Please provide more info. Just one suggestion: don't execute your PHP code in the middle of an HTML attribute
    – Pedro Serpa Nov 13 '18 at 15:50
  • Adding further screenshots isn’t really helpful - we believe you that the problem _exists_, but we can’t _do_ anything to find out what might cause it from merely looking at a picture. If you can not manage to show a proper example, then you’ll have to figure this out yourself. Inspect the element using your browser dev tools, and see which styling gets applied. – misorude Nov 13 '18 at 15:52
  • Oh my Gosh, i found it it's because of the indentation of the value property in the input that makes it to have alot of spacing before the echo. Thanks guys. And sorry for being a noob in asking question. Will learn from my mistake. – Oliver Sim Nov 13 '18 at 16:02
  • Possible duplicate of [How to align input forms in HTML](https://stackoverflow.com/questions/4309950/how-to-align-input-forms-in-html) – First Name Nov 13 '18 at 22:39

0 Answers0