Solved

Field Alignment in PHP

Posted on 2014-11-20
6
111 Views
Last Modified: 2014-11-27
I have a code using <li> and <ul> for alignment. However, the displayed field can't be aligned properly, Any idea ?
Screen.png
page-furniture-index.inc.txt
0
Comment
Question by:AXISHK
6 Comments
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 150 total points
ID: 40456644
First before you try to fix that, include a proper DOCTYPE just before '<html>'.  DOCTYPEs are the rules that the browser tries to apply to the page formatting.  The HTML5 DOCTYPE is the most current one.  Note that the DOCTYPEs are actual rules that the browser tries to follow and you need to follow them too to make your page display correctly.  Without a DOCTYPE like you have it now, each browser will display the page differently.  http://www.w3.org/QA/2002/04/valid-dtd-list.html

HTML5 DOCTYPE: <!DOCTYPE HTML>
0
 

Author Comment

by:AXISHK
ID: 40456651
Sorry, I attached a wrong source, should be this one...
page-furniture-products.inc.txt
0
 
LVL 11

Assisted Solution

by:Radek Baranowski
Radek Baranowski earned 150 total points
ID: 40456804
there are no ul/il tags in the second code
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 108

Accepted Solution

by:
Ray Paseur earned 200 total points
ID: 40457122
HTML formatting is not controlled by PHP; it's controlled by CSS.  Here are some links to help you get started.

http://www.w3.org/Style/CSS/learning.en.html (a collection)
http://www.codecademy.com/en/tracks/web (I have not used the CSS track, but the JavaScript track was excellent)
http://www.w3schools.com/css/ (appears to be fairly complete)

HTH, ~Ray
0
 
LVL 33

Expert Comment

by:Slick812
ID: 40458257
greetings  AXISHK, , I looked over your code in the file -
        page-furniture-products.inc.txt
there you use a HTML <table> to place ROWS of PRODUCTS, You ask -
       "However, the displayed field can't be aligned properly, Any idea ? "

Your <table> does align the columns as the CSS and HTML tells it to. You may need to try and learn about the positioning behavior of HTML <table> in it's <td> elements, so you can change the positions as you need to.
Before anything, you absolutely MUST NOT EVER HAVE anything between the <table> sections like -
   <tr> <td>
except spaces, tabs and line breaks. . . You can NOT place a <form> tag as you do with -
     echo "<form action='$_SERVER[PHP_SELF]' method='POST'>\n"
between the   </tr> and the next table <tr>, if you mix a <form> and a <table> together, as you do in this,  you need to have the <form> OUTSIDE of the <table> as the <table> container maybe like -

       echo "<form action='$_SERVER[PHP_SELF]' method='POST'>\n";
       echo "<input type='hidden' name='n_end' value='$n_end'>\n";
       echo "<input type='hidden' name='interest' value='$_POST[interest]'>";
// now place table inside of form
       echo "<table style='width: 100%'>\n";

In a <table>, any and all other HTML elements, need to be INSIDE of the beginning and end tags for <th> </th> or <td> </td>.

Your CSS uses inches as in -
       <body style='margin: .2in .2in 0'>
this is inconsistant for a screen display, and the browser can NOT interpret correctly that as inches. For screen use px or em.

Your bad alignment in the <table> is due to the default usual alignment for tables and your other text-align setting in the <td>

You might try to take out all <td> and <th> text-align css, and have your table be set as centered with -
      echo "<table style='width: 100%; text-align:center;'>\n";
ans see how that looks to you for alignment. If you still want the "Product Number" to be right aligned , then you can add the <td style='text-align: right;'> to the "Product Number" again.

Also you have two submit form buttons with a single same name, this is incorrect, all form inputs and buttons (submit) MUST have a different Unique name, not used as name anywhere else in that form.

ask questions if you need more info.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 40458637
Also you have two submit form buttons with a single same name, this is incorrect, all form inputs and buttons (submit) MUST have a different Unique name, not used as name anywhere else in that form.
This is factually inaccurate.  It's perfectly fine to have multiple input controls of the same name.  Otherwise how could radio buttons work?  Default values can be given in hidden fields and these can be overridden by client inputs.  You can have two submit controls of the same name and different values in order to signal different actions in the action= script, something like this:

<input type="submit" name="x" value="Update" />
<input type="submit" name="x" value="Delete" />

Open in new window


Accurate information about how HTML forms work is available from the W3C.
http://www.w3.org/TR/html401/interact/forms.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now