Newbie Coding Question

From: Date: Fri, 21 Feb 2003 05:46:45 +0000
Subject: Newbie Coding Question
Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-791@lists.php.net to get a copy of this message
Hello: Yes... it's another Newbie on the block :-) Smarty looks very awesome. I actually got the demo/test to work! But I could sure use some help in better understanding something to also pass along to someone who is going to help me with some PHP coding (I'll be doing the Templates in Dreamweaver): This is some PHP code to display alternating color rows for output for 3 fields. I would appreciate it greatly if anyone could help me (us) see how the .php and .tpl files should look which will be a great learning tool (and for practical use but with many more fields). Thank you very much! Eric ------ (Connect stuff omitted) 3 fields: name, phonenumber, and age Open up table and run a for loop for as many rows as exist and display the data. <?PHP echo "<TABLE BORDER=\"1\">\n"; echo "<TR bgcolor=\"lightblue\"><TD>Name</TD><TD>Phone</TD><TD>Age</TD></TR>\n"; for($i = 0; $i < $numofrows; $i++) {
    $row = mysql_fetch_array($result); //get a row from our result set
    if($i % 2) { //this means if there is a remainder
        echo "<TR bgcolor=\"yellow\">\n";
    } else { //if there isn't a remainder we will do the else
        echo "<TR bgcolor=\"white\">\n";
    }
    echo "<TD>".$row['name']."</TD><TD>".$row['phonenumber']."</TD><TD>".$row['age']. "</TD>\n";
    echo "</TR>\n";
} echo "</TABLE>\n"; ?>

« previous php.smarty.dev (#791) next »