3 lines of code not working

Thread Solved

Join Date: Oct 2007
Posts: 178
Reputation: lordx78 is an unknown quantity at this point 
Solved Threads: 2
lordx78's Avatar
lordx78 lordx78 is offline Offline
Junior Poster

3 lines of code not working

 
0
  #1
Mar 3rd, 2008
  1. <table align="left" style="width: 764px">
  2. <tr>
  3. <td>
  4. <?php
  5. $con =mysql_connect("localhost","root","");
  6. mysql_select_db("administration",$con);
  7.  
  8. $list=mysql_query("SELECT * FROM cycles");
  9. echo "<table border=1>";
  10. echo "<tr>" ;
  11. echo "<td align=center style='color:red'>CID</td>";
  12. echo "<td align=center style='color:green'>Brand</td>";
  13. echo "<td align=center style='color:red'>Type</td>";
  14. echo "<td align=center style='color:green'>Style</td>";
  15. echo "<td align=center style='color:red'>Model</td>";
  16. echo "<td align=center style='color:green'>Gear No</td>";
  17. echo "<td align=center style='color:red'>Frame</td>";
  18. echo "<td align=center style='color:green'>Group Set</td>";
  19. echo "<td align=center style='color:red'>Price</td>";
  20. echo "<td align=center style='color:green'>Release Date</td>";
  21. echo "</tr>";
  22.  
  23. $bg = '#eeeeee'; // Set the background color.
  24. while($row=mysql_fetch_array($list))
  25. {
  26. $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');
  27. echo "<tr>" ;
  28. echo "<td align=center>".$row['cycleID'] ."</td>";
  29. echo "<td align=center>".$row['brand']."</td>";
  30. echo "<td align=center>".$row['type']."</td>";
  31. echo "<td align=center>".$row['style']."</td>";
  32. echo "<td align=center>".$row['model'] ."</td>";
  33. echo "<td align=center>".$row['gearNo']."</td>";
  34. echo "<td align=center>".$row['frame']."</td>";
  35. echo "<td align=center>".$row['groupSet']."</td>";
  36. echo "<td align=center>".$row['price']."</td>";
  37. echo "<td align=center>".$row['releaseDate']."</td>";
  38. echo "</tr>";
  39. }
  40. echo "</table>";
  41. ?>
  42. </td>
  43. </tr>
  44. </table>

The code from line 23 - 26 is not functioning. Please help.
"I might not be the BEST but I'm not like the REST!"
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 11
Reputation: coffeepot! is an unknown quantity at this point 
Solved Threads: 2
coffeepot!'s Avatar
coffeepot! coffeepot! is offline Offline
Newbie Poster

Re: 3 lines of code not working

 
0
  #2
Mar 3rd, 2008
Hi, is the database throwing an exception? Does the code reach the closing table tag on line 40? Have you tried a record count to see if your row variable contains rows? try echoing the row count - otherwise the code looks fine.
Anything one man can make - another man will try to break.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 66
Reputation: silviuks is an unknown quantity at this point 
Solved Threads: 11
silviuks silviuks is offline Offline
Junior Poster in Training

Re: 3 lines of code not working

 
0
  #3
Mar 3rd, 2008
first of all ... where do you use $bg ? i don't see something like
echo "<td bgcolor='".$bg."'> .. if your rows are all white (or #eeeeee) this might be the problem.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 79
Reputation: rudevils is an unknown quantity at this point 
Solved Threads: 9
rudevils rudevils is offline Offline
Junior Poster in Training

Re: 3 lines of code not working

 
0
  #4
Mar 4th, 2008
Originally Posted by silviuks View Post
first of all ... where do you use $bg ? i don't see something like
echo "<td bgcolor='".$bg."'> .. if your rows are all white (or #eeeeee) this might be the problem.
I think silviuks, is right, you not using $bg as background color (you just set its value).
If love is blind, why there's a bikini ??

Post your article at Bali Side Notes share your knowledge
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 178
Reputation: lordx78 is an unknown quantity at this point 
Solved Threads: 2
lordx78's Avatar
lordx78 lordx78 is offline Offline
Junior Poster

Re: 3 lines of code not working

 
0
  #5
Mar 4th, 2008
I want to alternate the bg colours, row by row, any suggestion.
"I might not be the BEST but I'm not like the REST!"
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 107
Reputation: kings has a little shameless behaviour in the past 
Solved Threads: 2
kings's Avatar
kings kings is offline Offline
Junior Poster

Re: 3 lines of code not working

 
0
  #6
Mar 4th, 2008
<?php
@ $rpp; //Records Per Page
@ $cps; //Current Page Starting row number
@ $lps; //Last Page Starting row number
@ $a; //will be used to print the starting row number that is shown in the page
@ $b; //will be used to print the ending row number that is shown in the page


$q="Select SQL_CALC_FOUND_ROWS * from tablename";
$rs=mysql_query($q) or die(mysql_error());
$nr = mysql_num_rows($rs); //Number of rows found with LIMIT in actiong r

$q0="Select FOUND_ROWS()";
$rs0=mysql_query($q0) or die(mysql_error());
$row0=mysql_fetch_array($rs0);
$nr0 = $row0["FOUND_ROWS()"];
$i=$nr0;
while ($line=mysql_fetch_array($rs))
{
if($i %2 == 0)
{
echo "<tr>";
echo "<td>";
echo "<table bgcolor='#fefefe' width='73%' align='center' border='0'>";
echo "<tr><td width='25%'></td></tr>";
echo "</table>";
echo "</td>";
echo "</tr>";


}
else if($i %2 == 1)
{
echo "<tr>";
echo "<td>";
echo "<table bgcolor='#e5e1e1' width='73%' border='0' align='center'>";
echo "<tr><td width='55%'></td></tr>";
echo "</table>";
echo "</td>";
echo "</tr>";

}
$i--;
}
}
hope this works
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,747
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: 3 lines of code not working

 
0
  #7
Mar 4th, 2008
echo "<tr bgcolor=$bg>"; instead of echo "<tr>";
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 178
Reputation: lordx78 is an unknown quantity at this point 
Solved Threads: 2
lordx78's Avatar
lordx78 lordx78 is offline Offline
Junior Poster

Re: 3 lines of code not working

 
0
  #8
Mar 4th, 2008
Thanks guys, it solved.
"I might not be the BEST but I'm not like the REST!"
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC