Jump to content


php internal page


1 reply to this topic

#1 dtommy79

  • Members
  • 1 posts
  • Hungary

Posted 27 December 2007 - 03:50 PM

Hi,

I'd like to put this code in a php internal page. I can't get it work. The code should be ok, it's a phonebook script from the net. I guess it should be edited in order to work in an internal page but i have no clue what to do with it.:

<?php

for($i=0;$i<=25;$i++){
echo("<td> <A href='#A".chr(ord("A")+$i)."'>".chr(ord("A")+$i)." </a> </td");
}

?>
</tr>




<table border="0" cellpadding="0" width="600" align="left">
<?php


function connectSQL() {
global $ID,$csign;
if ($csign==1) return;
$ID=mysql_pconnect('localhost', 'user', 'pass');
mysql_selectdb("db",$ID);
$csign=1;
}

function closeSQL() {
global $ID,$csign;

if ($csign==1) mysql_close($ID);
$csign=0;
}

function query($qstr) {
global $ID,$res,$nur;
mysql_query("SET NAMES 'latin2'", $ID);
$res = mysql_query($qstr, $ID);
$nur = mysql_num_rows($res);
}

function next_row() {
global $ID,$res;
$row = mysql_fetch_assoc($res);
return $row;
}



connectSQL();

$query="select * from telszamok where '1' ORDER BY `NEV` ASC ";
query($query);
$szin=0;
// $jelen="";
$kell=0;
while($row=next_row()) {
$anc=substr($row["NEV"], 0, 1);
if ($anc!=$jelen) { $jelen=$anc; $kell=1; }




if ($szin==1) {$color="#E58354"; $szin=0;} else {$color="#CCCCCC"; $szin=1;}
$out="<tr bgcolor='$color'><td><p><b>$mhkep</b></p></td><td valign='TOP' width='30%'><p><B>";
if($kell==1) {
$out.="<A name='A".$jelen."'>";
}
$out.="<font color='#000066'>".$row["NEV"]."</font>";
if($kell==1) {
$out.="</a>";
$kell=0;
}
$out.="</b>
".$row["BEOSZTAS"]."</p></td><td valign='top'><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">";
$out.="<TR><TD ALIGN="LEFT">Mellék:</TD><TD ALIGN="LEFT"><B>".$row["MELLEK"]."</B></TD></TR>";
$out.="<TR><TD ALIGN="LEFT">Telefonszám:</TD><TD ALIGN="LEFT"><B>".$row["TELEFONSZAM"]."</B></TD></TR>";
$out.="<TR><TD ALIGN="LEFT">Mobilszám:</TD><TD ALIGN="LEFT"><B>".$row["MOBILSZAM"]."</B></TD></TR></TABLE>";
$out.="<TD valign='top'><p>Munkahely: <b>".$row["MUNKAHELY"]."</b>
";
$out.="E-mail cím: <a href="mailto:".$row["EMAILCIM"]."">".$row["EMAILCIM"]."</a><b></p></td></tr>";
echo($out);
}
?>
</table>


#2 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 28 December 2007 - 12:00 PM

Hello dtommy79-

Modifying this page will be a lot of work. And I do not have the database structure in order to test it.

Here is something to get you started. But the table structure needs work...

<?php

$content = '';

for($i=0;$i<=25;$i++){
$content .= "<td> <A href='#A".chr(ord("A")+$i)."'>".chr(ord("A")+$i)." </a> </td>";
}

$content .= '</tr>




<table border="0" cellpadding="0" width="600" align="left">
';


function connectSQL() {
global $ID,$csign;
if ($csign==1) return;
$ID=mysql_pconnect('localhost', 'user', 'pass');
mysql_selectdb("DB",$ID);
$csign=1;
}

function closeSQL() {
global $ID,$csign;

if ($csign==1) mysql_close($ID);
$csign=0;
}

function query($qstr) {
global $ID,$res,$nur;
mysql_query("SET NAMES 'latin2'", $ID);
$res = mysql_query($qstr, $ID);
$nur = mysql_num_rows($res);
}

function next_row() {
global $ID,$res;
$row = mysql_fetch_assoc($res);
return $row;
}



connectSQL();

$query="select * from telszamok where '1' ORDER BY `NEV` ASC ";
query($query);
$szin=0;
// $jelen="";
$kell=0;
while($row=next_row()) {
$anc=substr($row["NEV"], 0, 1);
if ($anc!=$jelen) { $jelen=$anc; $kell=1; }




if ($szin==1) {$color="#E58354"; $szin=0;} else {$color="#CCCCCC"; $szin=1;}
$out="<tr bgcolor='$color'><td><p><b>$mhkep</b></p></td><td valign='TOP' width='30%'><p><B>";
if($kell==1) {
$out.="<A name='A".$jelen."'>";
}
$out.="<font color='#000066'>".$row["NEV"]."</font>";
if($kell==1) {
$out.="</a>";
$kell=0;
}
$out.="</b>
".$row["BEOSZTAS"]."</p></td><td valign='top'><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1">";
$out.="<TR><TD ALIGN="LEFT">Mellék:</TD><TD ALIGN="LEFT"><B>".$row["MELLEK"]."</B></TD></TR>";
$out.="<TR><TD ALIGN="LEFT">Telefonszám:</TD><TD ALIGN="LEFT"><B>".$row["TELEFONSZAM"]."</B></TD></TR>";
$out.="<TR><TD ALIGN="LEFT">Mobilszám:</TD><TD ALIGN="LEFT"><B>".$row["MOBILSZAM"]."</B></TD></TR></TABLE>";
$out.="<TD valign='top'><p>Munkahely: <b>".$row["MUNKAHELY"]."</b>
";
$out.="E-mail cím: <a href="mailto:".$row["EMAILCIM"]."">".$row["EMAILCIM"]."</a><b></p></td></tr>";

$content .= $out;
}

$content .= '</table>';

?>
Also you do not need a new database connection to do the queries. You can use the MKPortal database connection since it already exists.

You need to fill in your correct database host, username, password, and database name in the correct places to make this block work as it is now.

I can convert this block to MKPortal for you for $50 USD but it will be Jan 15 before I can take on any new projects. If you need help working on this I will try to help you here on the forum for free but I have very little time until late January due to my very large workload.

-=DKC=-


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users