SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    936
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Arrow {section} won't work.

    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.

  2. #2
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Rather than assigning the array as $row[$id][$columnname], you are assigning it by $row[$columnname][$id].

    Yet in the template file (bearing in mind I haven't used Smarty, so I may be incorrect) it appears you are trying to call $row[$id][$columnname].
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •