Page 1 of 2
PHP in content
Posted: Fri Jan 20, 2006 10:21 am
by wientanz
Ok, don't laugh at me. I need to add some PHP code in my content for a DB request. And I know that I have to use other tags than .
I tried searching, but I can't find it anywhere. Help?
Re: PHP in content
Posted: Fri Jan 20, 2006 11:55 am
by westis
I'd say your best bet is to create a user-defined tag and then include that tag in your page.
Int he user-defined tag, leave out , as that is added automatically. The tag you insert on your page is then {nameoftag}. I think that should work.
Re: PHP in content
Posted: Fri Jan 20, 2006 11:56 am
by cyberman
It's called user defined tag - please look
here
.
Re: PHP in content
Posted: Fri Jan 20, 2006 12:02 pm
by wientanz
beat you to it by approx. 5 min.
Found it after googling the forum
Re: PHP in content
Posted: Fri Jan 20, 2006 12:10 pm
by wientanz
Since I've got a page mixed HTML and PHP between the lines I echo'ed the HTML so that I only have to use 1 tag. Copy&Pasted the edited code to userdefined plugins, inserted a {Pluginname}-tag into the content and voila... nothing happened
Can't believe I'm having all these troubles getting my old site adapted...
Re: PHP in content
Posted: Fri Jan 20, 2006 1:17 pm
by cyberman
Can you post the code?
Re: PHP in content
Posted: Fri Jan 20, 2006 1:39 pm
by wientanz
Here it is. The working script is found here:
http://www.wientanz.com/mitarbeiter/gab ... baelle.php
Code: Select all
require "http://www.wientanz.com/mitarbeiter/gabriel/datenbank/include/functions.inc";
echo "<div align=center>";
$res=mysql_query("select count(*) from ball;");
$arr=mysql_fetch_array($res);
$res2=mysql_query("select * from probe group by P_B_ID;");
echo "<p><font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">Derzeit haben
wir <b>$arr[0]</b> in unserer Liste, davon <b>".mysql_affected_rows()."</b>
mit Eröffnungsinformationen.</font></p>";
echo "<hr>";
$res = mysql_query("select B_ID, B_Desc, B_Date, B_Ort, B_Price, B_Info, B_EMail, month(B_Date), year(B_Date) from ball ORDER BY B_Date;");
$month=13;
$first=1;
echo "<table width=\"750\" border=\"0\">";
while($arr=mysql_fetch_array($res)) {
if($month!=$arr[7]) { //Print new TableHeader
$month=$arr[7];
$duo=1;
echo "<tr><td> </td></tr>
<tr bgcolor='#000066' bordercolor='#000066'>
<td colspan='6'>
<div align='center'><font size='3' color='#FFFFFF'><b><font face='Arial, Helvetica, sans-serif'><i>";
echo get_full_month($arr[7])." $arr[8]"; echo " </i></font></b></font></div>
</td>
</tr>
<tr bgcolor=#000066>
<td bordercolor=#000066><b><font color=#FFFFFF>Datum</font></b></td>
<td bordercolor=#000066><b><font color=#FFFFFF>Ball</font></b></td>
<td bordercolor=#000066><b><font color=#FFFFFF>Ort</font></b></td>
<td bordercolor=#000066><b><font color=#FFFFFF>Kartenpreise</font></b></td>
<td bordercolor=#000066><b><font color=#FFFFFF>Telefonnummer</font></b></td>
<td bordercolor=#000066><b><font color=#FFFFFF>Probeninfo</font></b></td>
</tr>";
} //End of TableHead
if($duo%2==0) $color="#99CCFF";
else $color="#0099FF";
$duo++;
echo "<tr bgcolor=\"$color\">";
echo " <td bordercolor=\"$color\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, san-serif\">".get_na_string($arr[2])."</font></td>";
echo " <td bordercolor=\"$color\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, san-serif\">".get_na_string($arr[1])."</font></td>";
echo " <td bordercolor=\"$color\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, san-serif\">".get_na_string($arr[3])."</font></td>";
echo " <td bordercolor=\"$color\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, san-serif\">".get_na_string($arr[4])."</font></td>";
echo " <td bordercolor=\"$color\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, san-serif\">".get_na_string($arr[5])."</font></td>";
echo " <td bordercolor=\"$color\"><font size=\"2\" face=\"Geneva, Arial, Helvetica, san-serif\">";
$res2=mysql_query("select P_Link FROM probe where p_b_id='$arr[0]';");
if(!$arr2=mysql_fetch_array($res2))
echo "N/A";
elseif(strlen($arr2[0])>1) echo "<a href=\"$arr2[0]\">Info</a>";
else echo "<a href=\"http://www.wientanz.com/mitarbeiter/gabriel/datenbank/ballinfo.php?B_ID=$arr[0]\">Proben</a>";
echo "</font></td>";
echo "<tr>";
}
echo "</table>
<br><hr><br>
<p><font size='2'>Datenbank wurde zuletzt aktualisiert: "; echo get_last_change(); echo "</font> </p>
<p> </p>
<p> </p>
</div>";
Re: PHP in content
Posted: Fri Jan 20, 2006 2:37 pm
by cyberman
I'm not a real coder

...
But if there's no solution you should try to include this part with Pi_Iframe from CMSMS Forge and you have nothing to change on the source

.
Re: PHP in content
Posted: Sat Jan 21, 2006 2:03 pm
by wientanz
I'll try that. Thanks for the idea. Didn't know that something like that exists...
Re: PHP in content
Posted: Sat Jan 21, 2006 3:15 pm
by wientanz
Stupid me, I named the tag wrong. Forgot an "l".
Now the tag works, but what I don't understand is why the umlaute like äüö and other characters like ß,é,è and the likes are displayed wrong. You'll find it here.
http://www.bugovsky.com/index.php?page=Ballkalender
The script is the same as on my original site (see link above) where the characters are correct.
Any ideas?
Now I'm off slipping into my tuxedo. There is a ball in town tonight! (As on any friday and saturday night in January and February in Vienna...)
Re: PHP in content
Posted: Sat Jan 21, 2006 3:23 pm
by wientanz
An idea: In the DB the data only has the umlaut itself and not the HTML equivalent. i.e. an ä and not an ä
The original script accepts it, but not CMSMS. Any ideas? Don't want to edit over a 160 entries by hand...
Re: PHP in content
Posted: Sat Jan 21, 2006 3:27 pm
by Russ
It is probably to do with character sets, you have no declaration in the web page HTML as far as I can see and it would also depend on the source of your data and perhaps your database settings if this is the source.
A normal html head declaration would be someting like (for UTF-8)
and you are also showing a language on your page of English, which doesn't seem right?
()
Hope this helps
Russ
Re: PHP in content
Posted: Sat Jan 21, 2006 3:32 pm
by Russ
I should also add that with UTF-8 character sets and these types of characters you need to be sending the page the correct sort of entities. e.g. & = & etc.
Have a search for utf-8 character set entities in Google.
Russ
Re: PHP in content
Posted: Sat Jan 21, 2006 7:35 pm
by cyberman
wientanz wrote:
Now the tag works, but what I don't understand is why the umlaute like äüö and other characters like ß,é,è and the likes are displayed wrong. You'll find it here.
You must set the encoding of your template to ISO-8859-1 to show the umlauts right.
Re: PHP in content
Posted: Sun Jan 22, 2006 2:25 am
by wientanz
THX cyberman, you're my hero. Will try it this Sunday.