I have a file that shows a table twice but there is only one table

This page shows a double table for open tickets. I just don’t get it, there is only one table in the code. When I remove the one table both disappear.

http://webhost.pro/blog/wp-content/uploads//2014/07/double.gif

[sup]1. <?php
include( “mypath.php” );
include( “{$filepath}/config/clientdbconnect.php” );
if ( ------------------------- )
{
#exit( “Security Violation” );
}
include( “header.php” );
$sqle = “select * from helpconfig where cid = ‘1’”;
if ( !( $resulte = mysql_query( $sqle ) ) )
{
exit( mysql_error( ) );
}
while ( $rowe = mysql_fetch_array( $resulte ) )
{
$ticketlimit = $rowe[‘ticketlimit’];
$ticketdlimit = $rowe[‘ticketdlimit’];
$flash = $rowe[‘flash’];
}
$interface = grab_template( “support_center_head.html”, $cusid );
$sqle = “select * from helpconfig where cid = ‘1’”;
if ( !( $resulte = mysql_query( $sqle ) ) )
{
exit( mysql_error( ) );
}
while ( $rowe = mysql_fetch_array( $resulte ) )
{
$chaturl = $rowe[‘chaturl’];
}
if ( $chaturl )
{
$chaturl = str_replace( “{username}”, $username, $chaturl );
$chaturl = str_replace( “{password}”, $password, $chaturl );
$interface = str_replace( “javascript: openwindow(‘chat.php’);”, “{$chaturl}”, $interface );
}
if ( $flash != “Y” )
{
$interface = str_replace( “<img src=”".$url."/templates/skin/button_flashtut.gif" width=“144” height=“35” border=“0”>", “”, $interface );
}
echo $interface;
$sqle = “select * from helpconfig where cid = ‘1’”;
if ( !( $resulte = mysql_query( $sqle ) ) )
{
exit( mysql_error( ) );
}
while ( $rowe = mysql_fetch_array( $resulte ) )
{
$supporturl = $rowe[‘supporturl’];
$chaturl = $rowe[‘chaturl’];
echo “<table width=“95%” border=“0” align=“center” cellpadding=“0” cellspacing= “0”>\n

\n \n <td valign=“top”><div align= “left”>\n <table width=“100%” border=“0” cellspacing=“0” cellpadding= “0”>\n \n <td width=“5%”><img src=”…/images/view- statistics.gif" width=“26” height=“20”> \n <td width=“95% “> My Help Requests\n \n \n \n \n \n \n <td width=“13” background=”…/images/leftbar.gif”> \n <td valign=“bottom” background="…/images/top-bar.gif"><div align=“right”>\n <td width=“16” background="…/images/rightbar.gif"> \n \n \n \n <table width=“100%” border=“0” align=“center” cellpadding=“2” cellspacing=“2” bordercolor="#FFFFFF">\n <tr bordercolor="#eeeeee" bgcolor="#f5f5f5">\n <div align=“left “><font color=”#000000”>Call\n ID\n <div align=“left”><font color="#000000">Status\n <div align=“left”><font color="#000000">Subject\n <div align=“left”><font color="#000000">Date\n Opened\n \n “;
$sqlc = “SELECT * from calls WHERE 1 AND status!=‘CLOSED’ and cid=’”.$cid.”’ LIMIT 0, 30";
if ( !( $resultc = mysql_query( “{$sqlc}” ) ) )
{
exit( mysql_error( ) );
}
while ( $rowc = mysql_fetch_array( $resultc ) )
{
$rowc[‘subject’] = str_replace( “&”, “&”, $rowc[‘subject’] );
$pid = $rowc[‘pid’];
echo " <tr bgcolor=’#f5f5f5’ onMouseOver=this.style.cursor=‘pointer’,this.style.backgroundColor=’#F4FAFD’ onMouseOut=this.style.backgroundColor=’#F5F5F5’ onclick=this.style.backgroundColor=’#84B5CB’,location.href=‘view_ticket.php?pid=".$pid."’ bordercolor=#FFFFFF>";
echo "
<a href=view_ticket.php?pid=".$pid.">";
echo $rowc[‘pid’];
echo “
<a href=view_ticket.php?pid=”.$pid."> “;
echo $rowc[‘status’];
echo "
<a href=view_ticket.php?pid=”.$pid.">";
echo $rowc[‘subject’];
echo "
“;
echo $rowc[‘date’];
echo “
”;
}
$totalrows = mysql_num_rows( $resultc );
if ( $totalrows == 0 )
{
echo " No Calls Opened “;
}
echo " \n \n \n \n <td background=”…/images/bottomleft.gif”> \n <td background= “…/images/bottom.gif”> \n <td background="…/images/bottomright.gif “> \n \n \n “;
}
echo “
\n<table width=“95%” border=“0” align=“center” cellpadding=“0” cellspacing=“0”>\n \n \n <td valign=“top”><div align=“center”>\n <table width=“100%” border=“0” cellspacing=“0” cellpadding=“0”>\n <a name=“statistics” id=“statistics”>\n <td width=“36”><div align=“center”><img src=”…/images/helpdesk.gif” width=“20” height=“16”>\n <td width=“96%”> Closed Tickets \n <td width=“36”> \n \n \n \n \n \n \n <td width=“13” background=”…/images/leftbar.gif"> \n <td valign=“bottom” background="…/images/top-bar.gif"><div align=“right”>\n <td width=“16” background="…/images/rightbar.gif"> \n \n \n \n <table width=“100%” border=“0” align=“center” cellpadding=“2” cellspacing=“2” bordercolor="#FFFFFF">\n <tr bordercolor="#eeeeee" bgcolor="#eeeeee">\n <td bordercolor="#eeeeee"><div align=“left”>Call ID \n <div align=“left”>Status \n <div align=“left”>Subject \n <div align=“left”>Date Opened \n \n “;
$a = 1;
$sqlc = “SELECT * from calls WHERE 1 AND status=‘CLOSED’ and cid=’”.$cid.”’ ORDER by pid DESC";
if ( !( $resultc = mysql_query( “{$sqlc}” ) ) )
{
exit( mysql_error( ) );
}
while ( $rowc = mysql_fetch_array( $resultc ) )
{
$rowc[‘subject’] = str_replace( “&”, “&”, $rowc[‘subject’] );
if ( $a == “3” )
{
$a = 1;
}
if ( $a == “1” )
{
$bgcolor = “#EEEEEE”;
}
else
{
$bgcolor = “#F5F5F5”;
}
$pid = $rowc[‘pid’];
echo " <tr onMouseOver=this.style.cursor=‘pointer’,this.style.backgroundColor=’#CCCCCC’ onMouseOut=this.style.backgroundColor=’#eeeeee’ onclick=this.style.backgroundColor=’#84B5CB’,location.href=‘view_ticket.php?pid=".$pid."’ bordercolor=#FFFFFF bgcolor={$bgcolor}>";
echo "
“;
echo $rowc[‘pid’];
echo "
“;
echo $rowc[‘status’];
echo "
<a href=view_ticket.php?pid=”;
echo $rowc[‘pid’];
echo “>”;
echo $rowc[‘subject’];
echo "
“;
echo $rowc[‘date’];
echo “
”;
$a += 1;
}
echo “”;
$totalrows = mysql_num_rows( $resultc );
if ( $totalrows == 0 )
{
echo " No Closed Tickets
”;
}
echo " \n \n \n \n <td background=”…/images/bottomleft.gif"> \n <td background="…/images/bottom.gif"> \n <td background="…/images/bottomright.gif"> \n \n\n<p align=“center”>";
include( “footer.php” );
echo “\n”;
?>[/sup]

It’s because you have it in a while loop, that most likely returns 2 rows…

Run this statement against your database directly…

[php]select * from helpconfig where cid = ‘1’[/php]

It will return 2 rows…

If you change it to …

[php]select * from helpconfig where cid = ‘1’ LIMIT 1[/php]

then you will get 1 row back

[member=69011]Topcoder[/member] , while that will work, it is not the correct way to handle it.

The opening and closing table tags should be outside a “while” or “foreach” loop while the opening and closing

DATA tags remain in the loop. The LIMIT 1 is not required when coded properly.

Additionally, looking at his posted image, it would seem he would want to display all rows for open help requests. Therefore, LIMIT 1 will never work. :smiley:

[member=46186]Kevin Rubio[/member]

I agree, I wasn’t trying to provide a solution. I was merely trying to explain why the table appeared twice.

But you’re right, providing your assumption is correct on what he wants to display, putting the table tags outside the loop is the correct thing to do.

Thanks, I will see if the patch will work and then try to re-code the table. Just not too savvy yet so work arounds are welcome.

The LIMIT 1 is not a patch. Do as I previously mentioned.

Can have you maybe pretty please paste how the code should be for that part? Sorry!

LIMIT 1 worked perfectly.

I will try the other way as well, glad to have it functional.

It’s actually not, but you will see.

Is that table supposed to show all open records?

Do what [member=46186]Kevin Rubio[/member] suggested. The patch was to just show you why it was happening, it’s not the correct solution.

O.K. it’s just interested that is worked, but thanks to both of you. I will do it and report back.

Thanks again.

Sponsor our Newsletter | Privacy Policy | Terms of Service