SkyRanger Posted April 16, 2007 Share Posted April 16, 2007 I am having a problem with my form: The following code is forcing my form down the page every time there is an entry leaving alot of white space above it. <? include "../inc/dbinfo.inc.php"; include('../variables.php'); $connection=mysql_connect ("$dblocation", "$dbusername", "$dbpassword") or die ('I cannot connect to the database because: ' . mysql_error()); //set up the query $querypl = mysql_db_query("$dbname", "SELECT * FROM support WHERE ticketno = '$ticketno'") or die("Unable to select Database"); $rowpl = mysql_num_rows($querypl); while ($rowpl = mysql_fetch_array($querypl)) { $sticketno = $rowpl["ticketno"]; $susername = $rowpl["username"]; $semail = $rowpl["email"]; $sdomain = $rowpl["domain"]; $ssubject = $rowpl["subject"]; $smessage = $rowpl["description"]; $sstatus = $rowpl["status"]; $sdate = $rowpl["date"]; } ?> <form method="post" action=<?PHP echo $PHP_SELF?>> <table width="80%" height="8" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#111111" id="AutoNumber10" style="border-collapse: collapse" valign="top"> <tr> <td width="84%" align="center" height="5" valign="top" colspan="2" bgcolor="#558FA2"> <p align="left"><font color="#FFFFFF"><b>Ticket Number: <?php echo $ticketno; ?></b></font></td> </tr> <input type="hidden" name="ticketno" value=<?php echo $ticketno ?>> <tr> <td width="21%" align="right" height="7" valign="top" bgcolor="#C0C0C0"> <p style="margin-right: 5">User:</td> <td width="63%" align="left" height="7" valign="top"> <p style="margin-left: 5"><?php echo $susername ?></td> </tr> <tr> <td width="21%" align="right" height="5" valign="top" bgcolor="#C0C0C0"> <p style="margin-right: 5">Email:</td> <td width="63%" align="left" height="5" valign="top"> <p style="margin-left: 5"><?php echo $semail ?></td> </tr> <tr> <td width="21%" align="right" height="6" valign="top" bgcolor="#C0C0C0"> <p style="margin-right: 5">Domain:</td> <td width="63%" align="left" height="6" valign="top"> <p style="margin-left: 5"><a href=http://<?php echo $sdomain ?> target="new"><?php echo $sdomain ?></a></td> </tr> <tr> <td width="21%" align="right" height="7" valign="top" bgcolor="#C0C0C0"> <p style="margin-right: 5">Date:</td> <td width="63%" align="left" height="7" valign="top"> <p style="margin-left: 5"><?php echo $sdate ?></td> </tr> <tr> <td width="21%" align="right" height="5" valign="top" bgcolor="#C0C0C0"> <p style="margin-right: 5">Subject:</td> <td width="63%" align="left" height="5" valign="top"> <p style="margin-left: 5"><?php echo $ssubject ?></td> </tr> <tr> <td width="21%" align="right" height="7" valign="top" bgcolor="#C0C0C0"> <p style="margin-right: 5">Original Question:</td> <td width="63%" align="left" height="7" valign="top" bgcolor="#66CCFF"> <p style="margin-left: 5"><?php echo nl2br("$smessage"); ?></td> </tr> <?php $querysr = mysql_db_query("$dbname", "SELECT * FROM `support_replies` WHERE ticketno = '$ticketno'") or die("Unable to select Database"); $rowsr = mysql_num_rows($querysr); while ($rowsr = mysql_fetch_array($querysr)) { $srticketno = $rowsr["ticketno"]; $srmessage = $rowsr["description"]; $srdate = $rowsr["date"]; $sruser = $rowsr["user"]; if($rownumber == "0"){ echo nl2br(" <tr> <td width=\"21%\" align=\"right\" valign=\"top\" bgcolor=\"#EEEEF8\"><p style=\"margin-right: 5\"><font color=\"#000000\">$sruser:</font></td> <td width=\"63%\" align=\"left\" valign=\"top\" bgcolor=\"#EEEEF8\"><p style=\"margin-left: 5\"><font color=\"#000000\">$srmessage</font></td> </tr>"); $rownumber = "1"; } else { echo nl2br("<tr> <td width=\"21%\" align=\"right\" valign=\"top\" bgcolor=\"#FBF7D7\"><p style=\"margin-right: 5\"><font color=\"#000000\">$sruser:</font></td> <td width=\"63%\" align=\"left\" valign=\"top\" bgcolor=\"#FBF7D7\"><p style=\"margin-left: 5\"><font color=\"#000000\">$srmessage</font></td> </tr>"); $rownumber = "0"; } } ?> <tr> <td width="21%" align="right" height="6" valign="top" bgcolor="#C0C0C0"> <p style="margin-right: 5">Add to Call:</td> <td width="63%" align="left" height="6" valign="top"> <p><textarea name="formmessage" cols="35" rows="6" wrap="true"></textarea></td> </tr> <tr> <td width="84%" align="right" height="7" valign="top" colspan="2"> </td> </tr> <tr> <td width="84%" align="right" height="8" valign="top" colspan="2"> <p align="center"><input type="Submit" name="submit" value="Send Reply"></td> </tr> <tr> <td width="84%" align="right" height="3" valign="top" colspan="2"> <p align="center"><a href=deletehd.php?ticketno=<?php echo $ticketno ?>>Delete Message</a> OR <a href=closehd.php?ticketno=<?php echo $ticketno ?>>Close Message</a> </td> </tr> <? } ?> </table></form> When I remove the following code it fixes the form alignment: <?php $querysr = mysql_db_query("$dbname", "SELECT * FROM `support_replies` WHERE ticketno = '$ticketno'") or die("Unable to select Database"); $rowsr = mysql_num_rows($querysr); while ($rowsr = mysql_fetch_array($querysr)) { $srticketno = $rowsr["ticketno"]; $srmessage = $rowsr["description"]; $srdate = $rowsr["date"]; $sruser = $rowsr["user"]; if($rownumber == "0"){ echo nl2br(" <tr> <td width=\"21%\" align=\"right\" valign=\"top\" bgcolor=\"#EEEEF8\"><p style=\"margin-right: 5\"><font color=\"#000000\">$sruser:</font></td> <td width=\"63%\" align=\"left\" valign=\"top\" bgcolor=\"#EEEEF8\"><p style=\"margin-left: 5\"><font color=\"#000000\">$srmessage</font></td> </tr>"); $rownumber = "1"; } else { echo nl2br("<tr> <td width=\"21%\" align=\"right\" valign=\"top\" bgcolor=\"#FBF7D7\"><p style=\"margin-right: 5\"><font color=\"#000000\">$sruser:</font></td> <td width=\"63%\" align=\"left\" valign=\"top\" bgcolor=\"#FBF7D7\"><p style=\"margin-left: 5\"><font color=\"#000000\">$srmessage</font></td> </tr>"); $rownumber = "0"; } } ?> Anybody have an Idea on how to fix that. so..the first code posted pushes the form down the page when I remove the section in the second code post it realigns the form back to where it is suppose to be. Link to comment https://forums.phpfreaks.com/topic/47275-solved-wierd-form-problem/ Share on other sites More sharing options...
marmite Posted April 16, 2007 Share Posted April 16, 2007 Isn't it because you have the while....loop echoing rows into your table? So, whenever there is a result from the DB, the code is writing lots of rows. Or did you mean that it's writing rows (which you want it to) AND adding lots of whitespace? Link to comment https://forums.phpfreaks.com/topic/47275-solved-wierd-form-problem/#findComment-230643 Share on other sites More sharing options...
SkyRanger Posted April 16, 2007 Author Share Posted April 16, 2007 Ok, with the top code that I posted I get: header <space> <space> <space> <space> <space> <space> <space> form with the bottom part removed I get: header <space> form Not sure why I am getting this problem. Not sure if there is something wrong with the nl2br code. And it gets worse with each reply. Link to comment https://forums.phpfreaks.com/topic/47275-solved-wierd-form-problem/#findComment-230648 Share on other sites More sharing options...
per1os Posted April 16, 2007 Share Posted April 16, 2007 echo nl2br("<tr> <td width=\"21%\" align=\"right\" valign=\"top\" bgcolor=\"#FBF7D7\"><p style=\"margin-right: 5\"><font color=\"#000000\">$sruser:</font></td> <td width=\"63%\" align=\"left\" valign=\"top\" bgcolor=\"#FBF7D7\"><p style=\"margin-left: 5\"><font color=\"#000000\">$srmessage</font></td> </tr>"); Wow man, that does not make sense?? This is what the above is outputting: <tr><br /> <td width=\"21%\" align=\"right\" valign=\"top\" bgcolor=\"#FBF7D7\"><p style=\"margin-right: 5\"><font color=\"#000000\">$sruser:</font></td><br /> <td width=\"63%\" align=\"left\" valign=\"top\" bgcolor=\"#FBF7D7\"><p style=\"margin-left: 5\"><font color=\"#000000\">$srmessage</font></td><br /> </tr> I do not think that is what you want? What are you trying to accomplish using the nl2br on a table declaration? This might better suit your needs echo "<tr> <td width=\"21%\" align=\"right\" valign=\"top\" bgcolor=\"#FBF7D7\"><p style=\"margin-right: 5\"><font color=\"#000000\"> " . nl2br($sruser) . ":</font></td> <td width=\"63%\" align=\"left\" valign=\"top\" bgcolor=\"#FBF7D7\"><p style=\"margin-left: 5\"><font color=\"#000000\">".nl2br($srmessage)."</font></td> </tr>"; Link to comment https://forums.phpfreaks.com/topic/47275-solved-wierd-form-problem/#findComment-230662 Share on other sites More sharing options...
SkyRanger Posted April 16, 2007 Author Share Posted April 16, 2007 Awsome, thanks frost, that fixed my problem, I never even thought of that when I kept checking the code. Link to comment https://forums.phpfreaks.com/topic/47275-solved-wierd-form-problem/#findComment-230668 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.