SkyRanger Posted April 23, 2009 Share Posted April 23, 2009 I am having a problem with this table. First I will post the full code then below that I will post the problem code and explain the problem further: <?php $ticketno = $_GET["ticketno"]; include "../inc/config.inc.php"; // database connect script. $connection=mysql_connect ("$dbhost", "$dbuname", "$dbpass") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("$dbname"); //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"]; } if( isset($_POST['submit'])) { // process form $formmessage = $_POST["formmessage"]; $postername = $myusername; // database connect script. include "../inc/config.inc.php"; // database connect script. $connection=mysql_connect ("$dbhost", "$dbuname", "$dbpass") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("$dbname"); mysql_db_query("$dbname", "UPDATE support SET status = 'pending' WHERE ticketno = '$ticketno'") or die('I cannot update the database because: ' . mysql_error()); $sql = "INSERT INTO support_replies (ticketno,description,date,user) VALUES ('$ticketno','$formmessage','time()','$postername')"; $result = mysql_query($sql) or die ('I could not add information to the database because ' . mysql_error()); echo "<b>Your request has been sent.</b><br>Please click here to return to the $dbcompany Manager Index:<br><a href=index2.php>$dbcompanyManager Index</a>"; } else{ ?> <form method="post" action=<?PHP echo $PHP_SELF?>> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber10" height="8" valign="top"> <tr> <td width="84%" align="center" height="5" valign="top" colspan="2" bgcolor="#A3A3D6"> Ticket Number: <?php echo $ticketno; ?></td> </tr> <input type="hidden" name="ticketno" value=<?php echo $ticketno ?>> <tr> <td width="21%" align="right" height="7" valign="top" bgcolor="#9999FF"> User:</td> <td width="63%" align="left" height="7" valign="top"> <?php echo $susername ?></td> </tr> <tr> <td width="21%" align="right" height="5" valign="top" bgcolor="#9999FF"> Email:</td> <td width="63%" align="left" height="5" valign="top"> <a href=email.php?aemail=<?php echo $semail ?>><?php echo $semail ?></a></td> </tr> <tr> <td width="21%" align="right" height="6" valign="top" bgcolor="#9999FF"> <p style="margin-right: 5">Domain:</td> <td width="63%" align="left" height="6" valign="top"> <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="#9999FF"> Date:</td> <td width="63%" align="left" height="7" valign="top"> <?php echo $sdate ?></td> </tr> <tr> <td width="21%" align="right" height="5" valign="top" bgcolor="#9999FF"> Subject:</td> <td width="63%" align="left" height="5" valign="top"> <?php echo $ssubject ?></td> </tr> <tr> <td width="21%" align="right" height="7" valign="top" bgcolor="#9999FF"> Original Question:</td> <td width="63%" align="left" height="7" valign="top" bgcolor="#66CCFF"> <?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\" bgcolor=\"#EEEEF8\"><font color=\"#000000\">$sruser:</font></td> <td width=\"63%\" align=\"left\" bgcolor=\"#EEEEF8\"><font color=\"#000000\">$srmessage</font></td> </tr>"); $rownumber = "1"; } else { echo nl2br("<tr> <td width=\"21%\" align=\"right\" valign=\"top\" bgcolor=\"#FBF7D7\"><font color=\"#000000\">$sruser:</font></td> <td width=\"63%\" align=\"left\" valign=\"top\" bgcolor=\"#FBF7D7\"><font color=\"#000000\">$srmessage</font></td> </tr>"); $rownumber = "0"; } } ?> <tr> <td width="21%" align="right" height="6" valign="top" bgcolor="#9999FF"> 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" bgcolor="#666699" colspan="2"> </td> </tr> <tr> <td width="84%" align="right" height="8" valign="top" bgcolor="#666699" colspan="2"> <p align="center"><input type="Submit" name="submit" value="Send Reply"></form></td> </tr> <tr> <td width="84%" align="right" height="3" valign="top" bgcolor="#666699" 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> Problem Code: if($rownumber == "0"){ echo nl2br("<tr> <td width=\"21%\" align=\"right\" bgcolor=\"#EEEEF8\"><font color=\"#000000\">$sruser:</font></td> <td width=\"63%\" align=\"left\" bgcolor=\"#EEEEF8\"><font color=\"#000000\">$srmessage</font></td> </tr>"); $rownumber = "1"; } else { echo nl2br("<tr> <td width=\"21%\" align=\"right\" valign=\"top\" bgcolor=\"#FBF7D7\"><font color=\"#000000\">$sruser:</font></td> <td width=\"63%\" align=\"left\" valign=\"top\" bgcolor=\"#FBF7D7\"><font color=\"#000000\">$srmessage</font></td> </tr>"); $rownumber = "0"; } The problem I am having with this code is that it is forcing my table farther down the page and leaving white space at the top. If you need further information please ask. Not sure if I posted everything that is needed. When I remove the problem code. The table displays properly. Link to comment https://forums.phpfreaks.com/topic/155283-solved-not-sure-if-this-a-php-or-html-problem/ Share on other sites More sharing options...
SkyRanger Posted April 23, 2009 Author Share Posted April 23, 2009 Ok, just found out the problem. It was the nl2br ( I took it out and it fixed itself. Is there another way to put in the line breaks without using nl2br? Link to comment https://forums.phpfreaks.com/topic/155283-solved-not-sure-if-this-a-php-or-html-problem/#findComment-816989 Share on other sites More sharing options...
SkyRanger Posted April 23, 2009 Author Share Posted April 23, 2009 Found the problem, had to move the nl2br to inside of the code. Link to comment https://forums.phpfreaks.com/topic/155283-solved-not-sure-if-this-a-php-or-html-problem/#findComment-816991 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.