Forums | Mahara Community

Open Discussion /
plugin error show?


anonymous profile picture
Account deleted
Posts: 5

09 April 2015, 23:10

i building project use mahara.
i use template plugin from    mahara.hrz.tu-darmstadt.de/view/view.php?id=5259

copy paste them artefact/plugintemplate and install in administrator plugin. progress ok. but:

i try show database values from table which i created but no work
name table : student_database
fields: name, email
 
in index.php insert:

$con=mysql_connect("localhost","root","") or die ("Don’t cant database");
mysql_select_db("mahara",$con) or die ("Don’t cant database "); //student là tên database
mysql_set_charset('utf8',$con);
//---------------------------------------------------------------------------------
$result=mysql_query('SELECT * FROM student_database WHERE 1');
//student_database là tên bảng
$students=array();

while ($row=mysql_fetch_assoc($result))
{
$test="test";
$students[]=$row;

}

_______________

in index.tpl insert:

{section name=st loop=$students}
<table width="40%" border="1" cellspacing="4">
 
<tr>
<td><font><b>name: </b></font></td>
<td><font><b><bgcolor="#CCCCCC">{$students[st].name}</b></font></td>
</tr>
<tr>
<td>Email</td>
<td>{$students[st].email}</td>
</tr>
</table>
<br>
{/section}

it not working!!! i think error position query database .
plz check my code. help me thanks all guy

Ghada El-Zoghbi's profile picture
Posts: 122

10 April 2015, 10:25

Hi Conan,

You'll need to pass the array to the template so it can display it.

In index.php, you'll need to add (after $smarty is declared towards the bottom of the file):

$smarty->assign('students', $students);

Please give it a try and let me know how you go.

Cheers.

 

anonymous profile picture
Account deleted
Posts: 5

10 April 2015, 19:55

$smarty->assign("students",$students);
sory i had already it, i think mahara not use loop as i do

anonymous profile picture
Account deleted
Posts: 5

13 April 2015, 21:31

i already had fixed, thanks guy! hii
{section name=st loop=$students}  change {foreach from=$students item=st} 

4 results