Jump to content

[SOLVED] MYSQL/PHP/CSS


Aravinthan

Recommended Posts

Hi guys,

 

Here is my problem,

 

I am extracting data from a MYSQL table and formatting it into a table.

 

But what I want is that the first row should be:

 
<tr>

The second one to be:

 
<tr class='odd' >

Third one:

 
<tr>

And so on.... I am pretty sure its simple ,but I cant put my finger on it....  :facewall: :facewall: :facewall: :facewall:

Link to comment
https://forums.phpfreaks.com/topic/170514-solved-mysqlphpcss/
Share on other sites

Maybe im being stupid, but what do you mean by "row" when talking about html?

Are you trying to have some form of rotating table row color or themes?

 

Ie:

row1 black

row2 white

row3 black

row4 white

etc etc.

 

This is how i do rotating background colors:

 

<?php
$bgcol = "FFCC66";

// then in a while loop for mysql :

if ($bgcol == "FFCC66") { // this will rotate the value.
	$bgcol = "FFFF99";
	}else{
	$bgcol = "FFCC66";
}

echo "<tr bgcolor=\"#$bgcol\"><td>"; 


[code]

This isnt probably what youw ant, however you may beable to understand where im coming from? and modify it?

Link to comment
https://forums.phpfreaks.com/topic/170514-solved-mysqlphpcss/#findComment-899452
Share on other sites

tyen something like

 

$class = "class=\'odd\'";

// then in a while loop for mysql :

if ($class == "class=\'odd\'") { // this will rotate the value.
      $class = "";
      }else{
      $class = "class=\'odd\'";
   }

echo "<tr $class ><td>"; 


 

 

All were doing here is rotating a value in a var, you then echo thi svar into the echoes html .

 

Link to comment
https://forums.phpfreaks.com/topic/170514-solved-mysqlphpcss/#findComment-899458
Share on other sites

Nicely tought  ;D

 

 

But, Its not working, I am thinking maybe I am placing it wrong...

 

So here is the code:

	</tfoot>
	<?php
error_reporting(0);
$link = mysql_connect ("localhost", "", "")
	or die("mysql_error()");
	mysql_select_db ("liguehs_league", $link);
$class = "class=\'odd\'";
$action = $_GET['action'] ;
switch ($action) {
case "all":
// Toute les equipes

$result = mysql_query("SELECT * FROM `teams` ",$link);
					while($row = mysql_fetch_array($result))
			{
if ($class == "class=\'odd\'") { // this will rotate the value.
      $class = "";
      }else{
      $class = "class=\'odd\'";
   }
echo "<tr $class><td><a href='team.php?name=" .$row['team_name']. "'>" .$row['team_name']. "</a></td>";

 

Its only part of it.... But seems ot not be working

Link to comment
https://forums.phpfreaks.com/topic/170514-solved-mysqlphpcss/#findComment-899463
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.