Hello i have associative array in SMARTY.
PHP
Code:$arr = array(array( 'cid' => 0, 'title' => '', 'email' => '', 'add_date' => '')); $i = 0; #$result=mysql_query("SELECT * FROM your table LIMIT $limit1, $limit2"); $query = "SELECT * FROM castingcall LIMIT $limit1, $limit2"; $result=mysql_query($query) or die("Problem with the query: $query on line " . __LINE__ . '<br>' . mysql_error()); while($row = mysql_fetch_array($result)) { $arr["cid"][$i] = $row['castingid']; $arr["title"][$i] = $row['title']; $arr["email"][$i] = $row['email']; $arr["add_date"][$i] = $row['date_posted']; echo "<b>". $arr["cid"][$i] ."</b> "; echo " ". $arr["title"][$i]; echo "<br>"; $i++; } $adminsmarty->assign('rows', $arr);
TPL
Code:<table border="1"> <tr> <th>ID</th> <th>Title</th> <th>Email</th> </tr> {section name=rec loop=$rows} {strip} <tr bgcolor="{cycle values="#aaaaaa,#bbbbbb"}"> <td>{$rows[rec].cid}</td> <td>{$rows[rec].title}</td> </tr> {/strip} {/section} </table>
It's not printing the values of the array, can you spot the not?
Thank you.





Bookmarks