Jump to content

Help with table - double lines and date


SA Rob

Recommended Posts

Hi Folks,I am working on a table that can be veiwed at this linkThe code in this page is presented below.My problems are:

  1. I cannot get rid of the double line entry just below the heading on the left hand side table.
  2. I would like the date that is seen on th etable on the right hand side top corner to appear next to each tournament of corresponding name in the left hand side table, in th ecolumn provided.

 </P> <P><?php</P> <P>$connect = mysql_connect("localhost", "*****", "**********") or</P> <P>die ("Hey loser, check your server connection.");</P> <P>mysql_select_db("eghfya_M*******");</P> <P>$quey1="select * from _Form_Nr_4 ORDER BY `Date` ASC ";$result=mysql_query($quey1) or die(mysql_error());</P> <P>?></P> <P><!------------------------------------------------------------------><!				  THIS SECTION CHANGES THE MAIN HEADING		   > <!------------------------------------------------------------------><style type="text/css">.mytable{border-collapse:collapse;font-size:11px; color:#00008B; width:100%;}.mytable td {border:1px solid #D3E2FE;}</style></P> <P><table class="mytable"><td width="8%" align="center" bgcolor="#EFF5FB"><font style="font-size:11px" color="#00008B" face="Arial"><b>No</b></font></td><td width="24%" align="center" bgcolor="#EFF5FB"><font style="font-size:11px" color="#00008B" face="Arial"><b>TOURNAMENT</b></font></td><td width="10%" align="center" bgcolor="#EFF5FB"><font style="font-size:11px" color="#00008B" face="Arial"><b>DATE</b></font></td><td width="8%" align="center" bgcolor="#EFF5FB"><font style="font-size:11px" color="#00008B" face="Arial"><b>%</b></font></td></table><!--------------------------------------------------------------------><!  THIS SECTION COUNTS THE ROWS THAT ARE UNIQUE AND PROVIDES RESULT  >  <!--------------------------------------------------------------------><?php</P> <P>echo '<table class="mytable">';foreach($counter as $key => $value)</P> <P>{$percentage = round(($value/96)*100, 0);</P> <P>$row='<tr>  <td align="center" width="8%" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Calibri"><b>'.$value.'</b></font></td>  <td width="24%" align="left" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Calibri">'.$key.'</font></td>  <td align="left" width="10%" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Calibri">'.$date.'</font></td>  <td align="center" width="8%" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Calibri"><b>'.$percentage.'</b></font></td>  </tr>'; $row= str_replace('Date', 'Date', $row); </P> <P>$date=$row['Date'];echo "$row";</P> <P>}echo '</table>';?> </P> <P>

Link to comment
Share on other sites

I'm not sure how you copied that PHP code, but it's not correct. There are <p> tag in place of all of the linebreaks.I don't see the first issue you're taking about, but how do you get the dates that you want to show? Where are the dates coming from?

Link to comment
Share on other sites

You have a table for the heading, and table for the golfers info, even though you use the same percentage width for both tables, if the content in on of the cell is longer it will adjust to this width, so you will end up with discrepancy's in width of cells between the two tables.To fix combine into one table problem solved.

<table class="mytable"><tr><td width="8%" align="center" bgcolor="#EFF5FB"><font style="font-size:11px" color="#00008B" face="Arial"><b>No</b></font></td><td width="24%" align="center" bgcolor="#EFF5FB"><font style="font-size:11px" color="#00008B" face="Arial"><b>TOURNAMENT</b></font></td><td width="10%" align="center" bgcolor="#EFF5FB"><font style="font-size:11px" color="#00008B" face="Arial"><b>DATE</b></font></td><td width="8%" align="center" bgcolor="#EFF5FB"><font style="font-size:11px" color="#00008B" face="Arial"><b>%</b></font></td></tr><!--------------------------------------------------------------------><!  THIS SECTION COUNTS THE ROWS THAT ARE UNIQUE AND PROVIDES RESULT  >  <!--------------------------------------------------------------------><?phpforeach($counter as $key => $value){$percentage = round(($value/96)*100, 0);

Link to comment
Share on other sites

If I replace as suggested then the text that is replace is shown in black above the heading and not affect to the desired result.
What? you are just removing the </table>(end of header table) and <table>(start of golfer details), (Note i added in the <tr></tr> tags for the header row, as they were missing), which causes the tables to blend into one.The top heading row will retain it bgcolor styling, the rest will have the default styling as before.
Link to comment
Share on other sites

Where is $counter value coming from? this type of foreach is used for array access where the key is the tournament name and the No value is the value associated with it, you can only retrieve one value, unless you use a nested foreach loop, and are using a multidimensional array? is it a multidimensional array? the No value and percentage value use the same $value (What is this value suppose to represent, this and the percentage value does not make sense to me)foreach($counter as $key => $value) you would usually use a while loop to retrieve values from databaseIF you want to use the date value from the next table, you have to run and retrieve this date value first, and include this variable within the date cell as it is processed, afterwards is no good.

Link to comment
Share on other sites

Hi,Your understandings are correct.The $key is the amount of players per tournament "No" and the $value = Name of the tournament corresponding with that number.The date that I am trying to place is in the MySQL but it needs to correspond with the tournament as the tournament occurs on that day.The table is created from values / arrays in the adjacent table that is why I tried do a query in the table presented in order to create and find the info but sadly it did not work.Any correction of my code to get it to work would be appreciated

Link to comment
Share on other sites

The way i see of doing this, is because the listing from both tables is in exactly same order, but the left table is broken down to just show player numbers from each tournaments, just store the date value from right table in an array, then as you loop through left table, use a counter to bring up corresponding daterough example$tournamentdate = array();$currenttournament="";$loopcount=0;while(blah blah){if(myrow['tournament']!=$currenttournament){$tournamentdate[$loopcount]=myrow['date'];echo'<tr><td colspan="4">'.myrow['tournament'].'</td><td>'.myrow['date'].'</td><tr>';$loopcount++;}rest of code...$currenttournament=myrow['tournament'];}then reset loopcount, and while looping the foreach loop print the result in array for corresponding date.

$loopcount=0;<?phpecho '<table class="mytable">';foreach($counter as $key => $value){$percentage = round(($value/96)*100, 0);$row='<tr>  <td align="center" width="8%" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Calibri"><b>'.$value.'</b></font></td>  <td width="24%" align="left" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Calibri">'.$key.'</font></td>  <td align="left" width="10%" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Calibri">'.$tournamentdate[$loopcount].'</font></td>  <td align="center" width="8%" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Calibri"><b>'.$percentage.'</b></font></td>  </tr>'; $row= str_replace('Date', 'Date', $row); $date=$row['Date'];echo "$row";$loopcount++;}echo '</table>';?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...