php-windows Digest 20 Aug 2003 15:55:19 -0000 Issue 1879

Topics (messages 21191 through 21195):

Re: output a table
        21191 by: Svensson, B.A.T. (HKG)
        21194 by: Veselina Jecheva

db connection php & mssql & win2k
        21192 by: giko
        21193 by: Stephen

how to establish relationship in Mysql
        21195 by: Thomas Edward Lawrence

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Read your mail to fast:

Change, "$posts_info=0;", into: "$posts_info++;", then you
should get alternate colors.

 

-----Original Message-----
From: Anthony Ritter
To: [EMAIL PROTECTED]
Sent: 2003-08-20 02:36
Subject: [PHP-WIN] output a table

Hi...
I'm trying to output a table with alternate background color rows.

The following snippet outputs a table after connecting to a mySQL
database
with posts but all of the rows have the same bgcolor.

Any help with the syntax will be greatly appreciated.
Thank you.
Tony Ritter
........................................
<?

<table width=100% cellpadding=3 cellspacing=1 border=1>
   <tr>
   <th bgcolor=\"#497fbf\"><font color=\"#ffffff\">AUTHOR</font>
   </th>
   <th bgcolor=\"#497fbf\"><font color=\"#ffffff\">POST</font></th>
   </tr>";

   while ($posts_info = mysql_fetch_array($get_posts_res)) {
       $post_id = $posts_info['post_id'];
       $post_text = nl2br(stripslashes($posts_info['post_text']));
       $post_create_time = $posts_info['fmt_post_create_time'];
       $post_owner = stripslashes($posts_info['post_owner']);

       $color1 = "#CCFFCC";
       $color2 = "#BFD8BC";
       $posts_info = 0;
       $row_color = ($posts_info % 2) ? $color1 : $color2;

       //add to display
       $display_block .= "
       <tr>
       <td width=35% valign=top
bgcolor=\"$row_color\"><p>$post_owner<br>[$post_create_time]</td>
       <td width=65% valign=top
bgcolor=\"$row_color\"><p>$post_text<br><br>
       <a href=\"replytopost.php?post_id=$post_id\"><strong>REPLY TO
POST</strong></a></td>

       </tr>";

   }

  //close up the table
  $display_block .= "</table>";
?>




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

--- End Message ---
--- Begin Message --- Anthony,
You can use a variable ($i in the example) and increment its value in the while statement.
Then check its value - if its odd or not - this works:-)
Good luck:-))
Veselina


<? $i=0;
while($row = odbc_fetch_row($result))
{ $i++;
?>
<tr>
<td width="22%" align="center" bgcolor="#<? echo $i % 2 ? "F4F4F4" : "ddeeff"; ?>"><font>
<? echo odbc_result($result,5). " ". odbc_result($result,2). " ". odbc_result($result,3)." ".
odbc_result($result,4); ?> </font></td>
<td width="31%" align="center" bgcolor="#<? echo $i % 2 ? "F4F4F4" : "ddeeff"; ?>"><font><? echo odbc_result($result,1); ?> </font></td>
<td width="7%" align="center" bgcolor="#<? echo $i % 2 ? "F4F4F4" : "ddeeff"; ?>"><font><? echo odbc_result($result,6); ?></font></td>
<td width="20%" align="center" bgcolor="#<? echo $i % 2 ? "F4F4F4" : "ddeeff"; ?>"><font><? echo odbc_result($result,7); ?></font></td>
</tr>
<?
}
?>


At 20:36 8/19/03 -0400, Anthony Ritter wrote:
Hi...
I'm trying to output a table with alternate background color rows.

The following snippet outputs a table after connecting to a mySQL database
with posts but all of the rows have the same bgcolor.

Any help with the syntax will be greatly appreciated.
Thank you.
Tony Ritter
........................................
<?

<table width=100% cellpadding=3 cellspacing=1 border=1>
   <tr>
   <th bgcolor=\"#497fbf\"><font color=\"#ffffff\">AUTHOR</font>
   </th>
   <th bgcolor=\"#497fbf\"><font color=\"#ffffff\">POST</font></th>
   </tr>";

   while ($posts_info = mysql_fetch_array($get_posts_res)) {
       $post_id = $posts_info['post_id'];
       $post_text = nl2br(stripslashes($posts_info['post_text']));
       $post_create_time = $posts_info['fmt_post_create_time'];
       $post_owner = stripslashes($posts_info['post_owner']);

       $color1 = "#CCFFCC";
       $color2 = "#BFD8BC";
       $posts_info = 0;
       $row_color = ($posts_info % 2) ? $color1 : $color2;

       //add to display
       $display_block .= "
       <tr>
       <td width=35% valign=top
bgcolor=\"$row_color\"><p>$post_owner<br>[$post_create_time]</td>
       <td width=65% valign=top bgcolor=\"$row_color\"><p>$post_text<br><br>
       <a href=\"replytopost.php?post_id=$post_id\"><strong>REPLY TO
POST</strong></a></td>

</tr>";

}

  //close up the table
  $display_block .= "</table>";
?>




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

--- End Message ---
--- Begin Message ---
hi,

i try

$serdb="LOCALMACHINE"; #the name of the SQL Server
$dbdb="dbname"; #the name of the database
$userdb="userdb"; #a valid username
$passdb="passdb"; #a password for the username

# one line
$con=odbc_connect("Driver={SQL
Server};Server=".$serdb.";Database=".$dbdb,$userdb,$passdb)or die("
connessione non riuscita");
# one line

but it doesn't work ...

can anyone help me please?

bye

thank's a lot



--- End Message ---
--- Begin Message ---
Giko

You will need to tell us what the error message it is you get before we can
help you.

Stephen


----- Original Message ----- 
From: "giko" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, August 20, 2003 9:06 AM
Subject: [PHP-WIN] db connection php & mssql & win2k


> hi,
>
> i try
>
> $serdb="LOCALMACHINE"; #the name of the SQL Server
> $dbdb="dbname"; #the name of the database
> $userdb="userdb"; #a valid username
> $passdb="passdb"; #a password for the username
>
> # one line
> $con=odbc_connect("Driver={SQL
> Server};Server=".$serdb.";Database=".$dbdb,$userdb,$passdb)or die("
> connessione non riuscita");
> # one line
>
> but it doesn't work ...
>
> can anyone help me please?
>
> bye
>
> thank's a lot
>
>
>
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



--- End Message ---
--- Begin Message ---
May it establish relationship in Mysql as if we can establish relationship
between tables in Access ? If can , please tell me , I use php Myadmin and
EMS Mysql manager version 2.5 , thank you .



--- End Message ---

Reply via email to