Re: [PHP] Returning table rows from MySQL

2002-02-18 Thread Matt Drake

On Mon, 18 Feb 2002, Scott Saraniero wrote:

> I've got a piece of code below that works great for me. Now I would like to
> modify the rows with alternating colors in the displayed results. Any
> suggestions on how to do this?

Try this:

$Count = 0;
while ($Row = mysql_fetch_array($Result) {
print("");
print('');

...
$Count++;
}

You could probably replace $Count with some mysql function (it would be named 
something like
mysql_current_row($Result)), but I obviously don't know that much about it.

Matt



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Returning table rows from MySQL

2002-02-18 Thread Ford, Mike [LSS]

> -Original Message-
> From: Scott Saraniero [mailto:[EMAIL PROTECTED]]
> Sent: 18 February 2002 18:02
> To: [EMAIL PROTECTED]
> 
> I've got a piece of code below that works great for me. Now I 
> would like to
> modify the rows with alternating colors in the displayed results. Any
> suggestions on how to do this?

Easy one: see additional/changed lines below:

> 
>  
> $Host = "";
> $User = "";
> $Password = "";
> $DBName = "";
> $TableName = "";
> 
> $Link = mysql_connect($Host, $User, $Password);
> 
> $Query = "SELECT * FROM $TableName";
> 
> $Result = mysql_db_query($DBName, $Query, $Link);
> 
> 
> 
> print ("");
> print ("");
> print ("Song");
> print ("Artist");

  print "";  // ** missing in your original!! **

  $alt_color = TRUE;

> 
> while ($Row =mysql_fetch_array($Result)) {
> print ("");
  $class = $alt_color ? 'textOnColor' : 'textOnWhite';
> print ("$Row[song]");
> print ("$Row[artist1] 
> $Row[artist]");
> 
> 

  $alt_color = !$alt_color;
> 
> }
> print "";
> 
> 
> 
> 
> mysql_close($Link);
> 
> ?>
> 
> Thanks,
> Scott
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Returning table rows from MySQL

2002-02-18 Thread Rick Emery

");
print ("");
print ("Song");
print ("Artist");

while ($Row =mysql_fetch_array($Result)) {
print ("");
$ctr = -$ctr;
if( $ctr == 1) {
print ("$Row[song]");
print ("$Row[artist1] $Row[artist]");
}
else {
print ("$Row[song]");
print ("$Row[artist1] $Row[artist]");
}

print "";

}
print "";




mysql_close($Link);

?>

Thanks,
Scott


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php