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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.