Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > VodaHost Web Hosting Support > mySQL & PHP

Notices

mySQL & PHP Discussions, information and help with mySQL and PHP.

Reply
 
Thread Tools
  #1  
Old 08-24-2009, 09:39 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
Question Duplication when uploading from MySQL

Hi folks,

I have a page at www.gnjgf.co.za/doom.php

That is duplicating the top two rows.

Can someone please advise as to how I can get it to stop - that is I only want the top two rows to appear once.
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 09-03-2009, 01:16 AM
Watdaflip's Avatar
Major General
 
Join Date: Sep 2005
Location: Cincinnati, Ohio
Posts: 2,151
Default Re: Duplication when uploading from MySQL

You would have to post you code for me to tell you exactly what to do, however it is just a matter or moving that heading code outside of the loop
__________________

Register/Login Script
Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old 09-03-2009, 09:29 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
Default Re: Duplication when uploading from MySQL

Hi,

Please find code attached for your perusal.


PHP Code:
<?php
//------------------------------------------------------------------>
//  THIS SECTION CHANGES THE VALUES of <72 TO RED and PAR TO BLUE   >
//                                                                  >
//  INCLUDING THIS BELOW         echo findNumColor($row['d11']);    >
//------------------------------------------------------------------>
function findNumColor($var) {
  if(
intval($var) < 72) {
  return 
'<font color="Red">'.$var.'</font>';
  } elseif(
intval($var) == 72) {
  return 
'<font color="Blue">'.$var.'</font>';
  } else {
  return 
'<font color="Black">'.$var.'</font>';
  }
}
//-------------------------------------------------------------------
$connect mysql_connect("localhost""*****_robert""******") or
die (
"Hey loser, check your server connection.");
mysql_select_db("*******_DOOM");
$query="select * from strokeaverage ORDER BY `rank` ASC ";
$result=mysql_query($query) or die(mysql_error());
?>
<!------------------------------------------------------------------>
<!           THIS SECTION CHANGES WHAT THE TABLE LOOKS LIKE         >
<!------------------------------------------------------------------>
<TITLE></TITLE>
<link rel="StyleSheet" href="style.css" type="text/css">
</HEAD>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="3" align="center">
<tr align="left" valign="top"> 
<td class="title">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
</table>
 
<td>
<tr class="menu-bg"><td colspan=29><b>GAUTENG NORTH JUNIOR GOLF FOUNDATION - DOMESTIC SCORES ONLY</b></td>
</tr>
<tr class="menu-bg"><td><b>RANK</b></td><td><b>FULL NAME</b></td><td>D11</td><td>D12</td><td>D13</td><td>D14</td><td>D15</td><td>D16</td>
<td>D17</td><td>D18</td><td>D19</td><td>D20</td><td>D21</td><td>D22</td><td>D23</td><td>D24</td><td>D25</td><td>D26</td>
<td>D27</td><td>D28</td><td>D29</td><td>D30</td><td>D31</td><td>D32</td>
<td>D33</td><td>D34</td><td>D35</td><td>D36</td>
</tr>
 
<!------------------------------------------------------------------>
<!                  THIS SECTION CHANGES THE MAIN HEADING           > 
<!------------------------------------------------------------------>
<caption><b><font style="font-size:16px" color="#00008B" face="Arial">
<font><b><caption>
<!------------------------------------------------------------------->
<!    THIS SECTION FETCHES THE INFORMATION FROM THE MYSQL TABLE      >  
<!------------------------------------------------------------------->
<?php
$counter 
= array();
$last_rank "";
$firstNAsAString "";
while(
$row=mysql_fetch_array($result)){
//----------------------------------------------------------------------------------------------------
// THIS SECTION ADDS 3 EMPTY LINES IF THERE IS A SPLIT BUT ONLY AFTER SOME RECORDS HAVE BEEN DISPLAYED
//----------------------------------------------------------------------------------------------------
if($i AND $row['-rank'] != $last_rank){
echo 
'<tr>
<td colspan="29"></td>
</tr>'
;
}
//------------------------------------------------------
//            THIS SECTION ADDS HEADINGS                
//------------------------------------------------------
if ($row['-rank'] != $last_rank) {
echo 
'<tr>
<td colspan="29" align="center" bgcolor="#FFFFFF"><font style="font-size:11px" color="#00008B" face="Arial"><b>DOMESTIC STROKE AVERAGES</b></font></td>
</tr>'
;
echo 
'<tr>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:8px" color="#00008B" face="Arial"><b>RANK</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:8px" color="#00008B" face="Arial"><b>FULL NAME</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:8px" color="#00008B" face="Arial"><b>D 11</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:8px" color="#00008B" face="Arial"><b>D 12</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:8px" color="#00008B" face="Arial"><b>D 21</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 22</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 31</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 32</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 41</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 42</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 51</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 52</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 61</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 62</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 71</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 72</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 81</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 82</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 91</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D 92</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D101</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D102</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D111</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D112</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D121</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D122</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D131</b></font></td>
<td align="center" bgcolor="#D6D6D8"><font style="font-size:11px" color="#00008B" face="Arial"><b>D132</b></font></td>
</tr>'
;
}
echo 
'<tr><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
$row['rank'];
echo 
'</td><td bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
'<option value="'.$row['surname'].', '.$row['name'].'"><b>'.$row['surname'].'</b>, '.$row['name'].'</option>';
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d11']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d12']);
echo 
'</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d21']);
echo 
'</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d22']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d31']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d32']);
echo 
'</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d41']);
echo 
'</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d42']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d51']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d52']);
echo 
'</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d61']);
echo 
'</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d62']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d71']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d72']);
echo 
'</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d81']);
echo 
'</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d82']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d91']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d92']);
echo 
'</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d101']);
echo 
'</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d102']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d111']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d112']);
echo 
'</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d121']);
echo 
'</td><td align="center" bgcolor="#FFFFFF"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d122']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d131']);
echo 
'</td><td align="center" bgcolor="#F5F5F5"><font style="font-size:10px" color="#00008B" face="Arial">';
echo 
findNumColor($row['d132']);
if(
$row['i_wish_to_play'] != $last_wish_to_play)
{
// the first n words to extract
$n 4;
// extract the words
$words explode(" "$row['i_wish_to_play']);
// chop the words array down to the first n elements
$firstN array_slice($words1$n-1);
// glue the 3 elements back into a spaced sentence
$firstNAsAString implode(" "$firstN);
}
if(!isset(
$counter[$firstNAsAString]))
$counter[$firstNAsAString] = 0;
else
$counter[$firstNAsAString]++;
$last_wish_to_play $row['i_wish_to_play'];
$i++;
 echo 
'</td></tr>';
 
}
echo 
'</table>';
?>
When veiwing www.gnjgf.co.za/stevie/doom1.php a grey line appears at the top which says there is some input that is not necessary there.

I have got rid of the duplication byt still the extra line of gery shows.
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old 09-04-2009, 12:46 AM
mattski's Avatar
Master Sergeant
 
Join Date: Jan 2008
Location: Colorado
Posts: 64
Default Re: Duplication when uploading from MySQL

Your table structure is off. You have some unused table statements. You can delete the following code to clean up your table structure:

Code:

<tr align="left" valign="top"> 
<td class="title">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
</table>
 
<td>
Basically you are not using the table information from the first table declaration below the <body> tag down to the <tr class="menu-bg"> row.

I copied out the HTML output and removed these lines and it looks much better. It's now just a single table and not a nested table like you had before.
__________________
Mattski

http://www.ScorpioFire.com


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old 09-04-2009, 06:16 AM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
Default Re: Duplication when uploading from MySQL

Hi,

Again my thanks

It is good to know folk like yourselves
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old 09-04-2009, 06:45 AM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
Default Re: Duplication when uploading from MySQL

Hi,

Maybe you can help with the next step.

How do i select the 6 lowest values from a row and then divide to get an average - and let this action happen for all rows?
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT +1. The time now is 08:27 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2005-2009 VodaHost Web Hosting Your Perfect Web Host - All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203