|
|
#1 |
|
Junior Member
|
hello
i stored array in var then i want to display this array in the smarty the field in database where they stored in the var are name, email, comment ??? how can i do it look at what i did PHP Code:
so any idea for this ? Last edited by Abdulaziz; 05-19-2009 at 12:35 PM. |
|
|
|
|
|
#2 | |
|
Moderator
Join Date: Mar 2006
Posts: 4,218
Rep Power: 103 ![]() ![]() |
Quote:
Is your arfray multi-dimensionl? Have you assigned the value of $rs to the template? Try putting this in your template for testing purposes...... {php}print_r($rs){/php} This should print out the array in the template, probably at the top of the page, post what it prints out here.
__________________
Larry. (Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free) Set your site apart from the competition with one of my modules...... Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module 68 Classifieds Important Links Customer Area | Issue Tracker | Knowledge Base | User Manuals |
|
|
|
|
|
|
#3 |
|
Junior Member
|
i will explain
i created class guestbook which have this method PHP Code:
PHP Code:
PHP Code:
this is my first module and i would like to be in the right way so any idea please |
|
|
|
|
|
#4 |
|
Moderator
Join Date: Mar 2006
Posts: 4,218
Rep Power: 103 ![]() ![]() |
Assuming your the query to the database is working and collecting data the obvious problem I see is that you are assigning the php variable $rs to the template variable rss with this line...
$class_tpl->assign('rss', $rs); Then in the tamplate you are trying to get data from the smarty variable $rs with the following line {foreach from=$rs item="entry"} there is no smarty variable $rs, its rss as it appears in the template asignment.
__________________
Larry. (Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free) Set your site apart from the competition with one of my modules...... Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module 68 Classifieds Important Links Customer Area | Issue Tracker | Knowledge Base | User Manuals |
|
|
|
|
|
#5 |
|
Junior Member
|
thanks for your fast replay
i corrected the var $rss and when i test it i get only the first string from each field then i tried this code PHP Code:
what i want is to split the array and display it in template thanks in advance |
|
|
|
|
|
#6 |
|
68 Classifieds Staff
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,842
Rep Power: 111 ![]() |
Try this:
PHP Code:
__________________
Eric Barnes 68 Classifieds Developer Please do not send me a private message asking for support. Instead use these open forums or our ticket system. Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules |
|
|
|
|
|
#7 |
|
Moderator
Join Date: Mar 2006
Posts: 4,218
Rep Power: 103 ![]() ![]() |
The problem here as I see it is he is only pulling 1 record from the database and doesnt seem to be stating which record he is pulling.
He is using.... $data=$result->fetch(); which uses mysql_fetch_array to load the returned array into $data thereby making it a multidimensional array. then at the template level looping over the $data array(which there is nothing to loop over because there was only 1 record pulled from DB) and trying to display the contents as a regular variable when in essence its another array.
__________________
Larry. (Please note: I am not a 68C employee. I am a customer and volunteer who helps with questions where I can and the forums spam free) Set your site apart from the competition with one of my modules...... Google Map Module | You Tube Module | Google Calendar Module | Event Calendar Module 68 Classifieds Important Links Customer Area | Issue Tracker | Knowledge Base | User Manuals |
|
|
|
|
|
#8 |
|
Junior Member
|
hello Eric
i did what did you write and nothing happen ![]() look at what has appeared 5 a g "5 is the id , a is the first of abdulaziz, g is the first of good" that what are appear the record in the database as picture in attachment also u can visit the url to see that ??????? ?????? ? ????? ??????? ??????? ?????? ?????? ?????? ????????? and one more thing if it possible to setup 68classified in the localhost? |
|
|
|
|
|
#9 |
|
68 Classifieds Staff
Join Date: Mar 2006
Location: Belmont, NC
Posts: 4,842
Rep Power: 111 ![]() |
Yes I think Larry was on to something. See if this works:
PHP Code:
__________________
Eric Barnes 68 Classifieds Developer Please do not send me a private message asking for support. Instead use these open forums or our ticket system. Customer Area | Issue Tracker | Documentation | 68C Mods | Submit a Ticket | 68 @ Twitter | My Modules |
|
|
|
|
|
#10 |
|
Junior Member
|
I am greatful that you solved my problem it's working very well now
sending you my best regards |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Hook for template display()? | cheesegrits | v4 Questions & Support | 4 | 01-14-2008 11:59 AM |
| Array | Jessej | v3.1 Questions & Support | 18 | 11-29-2007 09:04 AM |
| extra field check boxes output "array" | markyy | v3.1 Questions & Support | 0 | 11-16-2007 12:22 AM |
| listing extra field value when it is an array? | Mike-N-Tosh | v3.1 Modules & Modifications | 13 | 04-21-2007 09:31 AM |
| Displaying a Multidimensional Array Results in Smarty | Maffo | v3.1 Questions & Support | 7 | 12-20-2006 08:41 AM |