1
sarahmx
add php code and mysql query in any content module editor ?
  • 2010/2/24 14:14

  • sarahmx

  • Quite a regular

  • Posts: 381

  • Since: 2007/10/28


maybe this a stupid question


How do i properly add my php code or MySQL query to a content module like news or content ...

?

i put my code in basic editor and it is not display correctly in browser..

help

2
sarahmx
Re: add php code and mysql query in any content module editor ?
  • 2010/2/26 23:08

  • sarahmx

  • Quite a regular

  • Posts: 381

  • Since: 2007/10/28


bump

3
ForMusS
Re: add php code and mysql query in any content module editor ?
  • 2010/2/26 23:44

  • ForMusS

  • Core Developer

  • Posts: 146

  • Since: 2007/10/19


You must use code balise for display code

MusS

4
sarahmx
Re: add php code and mysql query in any content module editor ?
  • 2010/2/27 1:03

  • sarahmx

  • Quite a regular

  • Posts: 381

  • Since: 2007/10/28


i don't want to display the code...

i want to run the code

what i want to do is actually to show a data using query from database

5
sarahmx
Re: add php code and mysql query in any content module editor ?
  • 2010/3/3 13:16

  • sarahmx

  • Quite a regular

  • Posts: 381

  • Since: 2007/10/28


anyone ?

is this even possible ?

6
kaotik
Re: add php code and mysql query in any content module editor ?
  • 2010/3/3 13:25

  • kaotik

  • Just can't stay away

  • Posts: 861

  • Since: 2004/2/19


Are you tring to add content to a module or to a wysiwyg editor?

For the first:
Yes it's possible. There are 2 ways of accomplishing this:
1- Without use of smarty templates
In this case open the corresponding php file (for ex: article.php), perform your db query and output the result [echo $var;]. Be advised that this method could break ajax functionality if it exists in the module.
2- With smarty templates
This method stats the same as method 1, but instead of using an "echo" you will insert a new smarty var. This requieres changes in 2 files; the php file and smarty template.

7
sarahmx
Re: add php code and mysql query in any content module editor ?
  • 2010/3/3 15:21

  • sarahmx

  • Quite a regular

  • Posts: 381

  • Since: 2007/10/28


i dont understand kaotik..im new to php and i think i should explain myself again..sorry my english sucks

what i really want to do is to post an article using the content module by formuss..

in the article i want to show a table ..the data in the table is from my db


example of my query
<?php
global $xoopsDB;
$result mysql_query("SELECT * FROM ".$xoopsDB->prefix("section_info")." WHERE Unit='Pharmacy' ORDER BY senioriti");

$count =1;
echo 
"<table><tr class='head'>";
echo 
"<td>No</td>";
echo 
"<td>Name</td>";


$style=0;

while(
$row mysql_fetch_array($result))
{
$my_id=$row['my_id']; 

echo 
'<tr class="', ++$style 'even' 'odd''">'
echo 
"<td>"
echo 
$count++;
echo 
"</td>";
echo 
"<td><b>" $row['name'] . "</b></td>";
echo 
"</tr>";
}
 echo 
"</table>";echo "";
  
?>


so how can i use the code above to post it in my content ?

8
sarahmx
Re: add php code and mysql query in any content module editor ?
  • 2010/3/5 16:44

  • sarahmx

  • Quite a regular

  • Posts: 381

  • Since: 2007/10/28


bump

9
frankblack
Re: add php code and mysql query in any content module editor ?
  • 2010/3/5 16:54

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


You cannot execute PHP when you paste it into any content module. But you can use jquery/Ajax to do this for you. You "just" have to write an Ajax to pull some information from the database and load into a div or something else.

Should work? One obstacle could be, that - depending on the used editor - javascript might be filtered. But tinymce or tinyeditor (others I don't know) can be configured that way, that javascript is allowed.

10
sarahmx
Re: add php code and mysql query in any content module editor ?
  • 2010/3/5 16:59

  • sarahmx

  • Quite a regular

  • Posts: 381

  • Since: 2007/10/28


thanks for the idea....frankblack

will learn ajax asap..and try this soon.......will post here for update and problem

Login

Who's Online

151 user(s) are online (105 user(s) are browsing Support Forums)


Members: 0


Guests: 151


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits