|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Bloodmorphed Smarty Rookie
Joined: 20 Aug 2017 Posts: 8
|
Posted: Sun Aug 20, 2017 2:08 am Post subject: Pulling a DB looping it as options |
|
|
I have a table that is only 2 columns (id, name).
I got this to work yesterday with just name and after changing it i cant get it to work again.
Code: |
else
{
$query = $this->db->execute('SELECT * FROM `<ezrpg>mobs`');
$mobs = $this->db->fetchAll($query);
$this->tpl->display('battle.tpl');
}
|
That's my PHP file.
Heres how I'm using it in template
Code: |
<form method="post" action="index.php?mod=Battle">
<select name="selection">
{foreach from=$mobs item=mob}
<option value="{$mob->name}">{$mob->name}({$mob->id})</option>
{/foreach}
</select>
<input name="battle_mob" type="submit" value="Fight" class="button" />
</form>
|
i tried doing a while loop and assigning, individually and separately but to no avail. Any ideas would be wonderful![/code] |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Sun Aug 20, 2017 3:59 am Post subject: |
|
|
I am not familiar with the syntax you are using. I will make several assumptions.
Apart from the assumptions, add {debug} to the template and let the browser open a popup window. Make sure $mobs has been assigned to the template variable "mobs". If it has, it will be shown in the debug popup. |
|
Back to top |
|
Bloodmorphed Smarty Rookie
Joined: 20 Aug 2017 Posts: 8
|
Posted: Sun Aug 20, 2017 5:02 am Post subject: |
|
|
Well, that was easy. assigning it worked, I could have sworn i had done it multiple times. I must have done a mistype or something.
Thanks! |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|