Jakesta42 Posted February 17, 2012 Share Posted February 17, 2012 Hello, I'm writing a PHP program in which textfields are printed (in a loop) into an HTML table. On a button click, another column is added to the table, and another textfield added. The problem is that when a new textfield is printed, it is slightly above the height of the other textfields (see attached picture if unclear). The code for this is below: <table border = '1' cellspacing = '4' style = "color: white"> <?php include "connectToDatabase.php"; //Initial script call to generate table from database ?> </table> //Code in connectToDatabase.php... $query = mysql_query("SELECT * FROM colin_table"); while($row = mysql_fetch_array($query)){ //$row represents each row in an array for($i = 0; $i < $limit; $i++){ //Print every element in the array if($row[$i] == null) echo "<td align = 'center'><input type = 'text' style = 'text-align: center; vertical-align: middle' align = 'center'>"; else echo "<td align = 'center'>" . $row[$i]; } echo "<td align = 'center'>"; echo "<tr align = 'center'>"; //Then move to the next row } //Loop that prints text boxes for every column in the HTML table $textBoxQuery = mysql_query("SELECT * FROM allColumnFields"); while($row = mysql_fetch_array($textBoxQuery)){ echo <<<END <td align = 'center'> <input type = 'text' style="margin-left:auto; text-align:center; vertical-align: middle; margin-right:auto;" name = "rowField"/> END; //THIS IS THE PART THAT NEEDS WORK. FOR SOME REASON NEW TEXTBOX IS HIGHER THAN THE OTHER BOXES } It's more of an aesthetic problem, but it's nonetheless something I'd like to get fixed. Any ideas? Jake Quote Link to comment https://forums.phpfreaks.com/topic/257208-basic-html-textfield-alignment-in-table-column-question/ Share on other sites More sharing options...
scootstah Posted February 17, 2012 Share Posted February 17, 2012 It could be due to the fact that your code is going to open a ton of table rows and cells but close none of them. Quote Link to comment https://forums.phpfreaks.com/topic/257208-basic-html-textfield-alignment-in-table-column-question/#findComment-1318444 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.