pquery Posted June 17, 2008 Share Posted June 17, 2008 Hello, I'm having a little trouble having my smarty template which is generating Here is the main code of the tpl file which is doing the work: {foreach from=$candidates key=myId item=i} <tr> <td align="right"><input type="checkbox" name="candidate[]" value="{$i.applicationID}"> </td> <td align="left"> {$i.firstName} {$i.lastName}</td> <td> <select name="station[]"> {html_options options=$stations} </select> </td> </tr> {/foreach} And here is the code from my php file that is generating the actual page: WHILE ( $row = mysql_fetch_array($result)) { //print_r($row); $candidates[] = $row; } $smarty->assign("stations", $stations); $smarty->assign("assessors", $assessors); $smarty->assign("candidates", $candidates); And finally the row output from a print_r statement (names have been starred out to protect the innocent ) Array ( [0] => Array ( [0] => 8965dd88 [applicationID] => 8965dd88 [1] => S*** [firstName] => S*** [2] => G*** [lastName] => G*** ) ) I've tried building this array about 5 different ways, but nothing seems to be working right for me. I've also noticed that the server I'm using is using PHP 5.1.6 so array_fill_keys wouldn't work for me any ideas are appreciated. Link to comment https://forums.phpfreaks.com/topic/110637-solved-help-creating-a-dynamic-array-with-keys-other-then-numbers/ Share on other sites More sharing options...
Barand Posted June 17, 2008 Share Posted June 17, 2008 use mysql_fetch_assoc() instead of mysql_fetch_array() Link to comment https://forums.phpfreaks.com/topic/110637-solved-help-creating-a-dynamic-array-with-keys-other-then-numbers/#findComment-567597 Share on other sites More sharing options...
pquery Posted June 18, 2008 Author Share Posted June 18, 2008 Thanks, I was looking all in the key functions and never even though to look there Link to comment https://forums.phpfreaks.com/topic/110637-solved-help-creating-a-dynamic-array-with-keys-other-then-numbers/#findComment-568085 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.