Jump to content
php.lv forumi

atbriivotiesno vienas funkcijas


djmartins

Recommended Posts

Kaa lai tiek valaa no funkcijas ShowGroups, cipa lai ka veras lapa valaa uzreiz raadas funkcija DisplayGroup.Meginaju itka vienkarsi izdzest bet tur it ka erorus met araa.NU nez varbuut jums ir ideja

 

 

<?php

 

$title = "Ziņas";

include "functions.php";

include("header.php");

 

if ($action == "category") DisplayGroup();

else if ($action == "shownews") ShowNews();

else ShowGroups();

 

include("footer.php");

 

 

Function ShowGroups()

{

?>

<br/>

<table width="630" cellspacing="1" cellpadding="1" bgcolor="#<?=_COLOR02;?>" align="center" class="MojHeadt">

<tr>

<td><?=$GLOBALS['title'];?></td>

</tr>

</table>

 

 

<table width="630" border="0" cellspacing="1" cellpadding="2" align="center" class="MojHead">

<tr>

<td>

<?php

$res = mysql_query("SELECT * FROM ".$GLOBALS['db_topic']." ORDER BY topictext");

echo '<table width="630"><tr>';

while ($ar = mysql_fetch_array($res))

{

$x++;

print "<td align=\"center\" height=\"100\"><a href=\"?action=category&id=$ar[id]\">$ar[topictext]</a></td>";

if ($x == 5) { print "</tr><tr>";$x=0;}

}

?>

</tr></table>

</td>

</tr>

</table>

<?

}

 

Function DisplayGroup()

{

if(!check_version("4.1.0")) global $_GET;

 

$res = mysql_query("SELECT * FROM ".$GLOBALS['db_topic']." where id='".$_GET['id']."'");

$tp = mysql_fetch_array($res)

?>

<br/>

<table width="630" border="0" cellspacing="1" cellpadding="2" bgcolor="#<?=_COLOR02;?>" align="center" class="MojHead">

<tr>

<td><a href="<?=$GLOBALS['PHP_SELF'];?>"> <?=$GLOBALS['title'];?></a> :: <?=$tp[topictext];?></td>

</tr>

</table>

 

<table width="630" border="0" cellspacing="1" cellpadding="2" class="MojHeadt">

<tr>

<td>

<?

 

$res = mysql_query("SELECT * FROM ".$GLOBALS['db_news']." WHERE category='".$_GET['id']."' ORDER BY datum DESC");

while ($ar = mysql_fetch_array($res))

{

ereg ("([0-9]{4})([0-9]{1,2})([0-9]{1,2})([0-9]{1,2})([0-9]{1,2})([0-9]{1,2})", $ar[datum], $datetime);

$datum = date("M jS ", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));

$x++;

print "$x.<a href=\"?action=shownews&category=".$_GET['category']."&id=".$_GET['id']."&topicid=$ar[id]\">$ar[headline] / $datum</a><br/>";

}

?>

</td>

</tr>

</table>

<?

}

 

Function ShowNews()

{

if(!check_version("4.1.0")) global $_GET;

$res = mysql_query("SELECT * FROM ".$GLOBALS['db_topic']." WHERE id='".$_GET['id']."'");

$tp = mysql_fetch_array($res)

?>

 

<br/>

<table width="630" border="0" cellspacing="1" cellpadding="2" bgcolor="#<?=_COLOR02;?>" align="center" class="MojHead">

<tr>

<td width="100%" bgcolor="#<?=_COLOR02;?>">

<a href="<?=$GLOBALS['PHP_SELF'];?>"><?=$GLOBALS['title'];?></a> :: <a href="?action=category&id=<?=$_GET['id'];?>"><?=$tp[topictext];?></a>

</td>

</tr>

</table>

<br/>

<table width="630" border="0" cellspacing="1" cellpadding="2" align="center" class="MojHead">

<tr>

<td>

<?

$res = mysql_query("SELECT * FROM ".$GLOBALS['db_news']." where id='".$_GET['topicid']."'");

while ($ar = mysql_fetch_array($res))

{

$res2 = mysql_query("SELECT email FROM ".$GLOBALS['db_admin']." WHERE uname='$ar[author]'");

$ar2 = mysql_fetch_array($res2);

$datum = formatTimestamp($ar[datum]);

echo "</td></tr></table>";

?>

<table width="630" cellspacing="1" cellpadding="2" class="MojText">

<tr><td class="MojHead"><?=$ar[headline];?></td></tr>

<tr>

<td>

<p style="width:630; text-align:justify;" class="MojText">

<?

if(!empty($ar[picture]) && file_exists($GLOBALS['news_url'].$ar[picture]))

echo '<img src="'.$GLOBALS['news_url'].$ar[picture].'" align="left" style="padding-right:4pt;">';

echo $ar[preview];

?>

</p>

<p style="width:630; text-align:justify;" class="MojText"><?=$ar[tekst];?></p>

</td>

</tr>

</tr>

</td>

</td>

</tr>

<tr><td>

<br/>

Ievietots: <?=$datum;?> Ievietoja: <?=$ar[author];?></a>

</td>

</tr>

</table>

<br/><br/>

<?

}

 

}

?>

Link to comment
Share on other sites

1) Izlasi noteikumus par paaraak gariem kodiem;

2) Lieto mosh switch ?

 

Ja es pareizi sapratu, ko Tu veelies, tad pameegjini varbuut shaadi:

 

switch($action) {
  case 'category':
     DisplayGroup();
     break;

  case 'shownews':
     ShowNews();
     break;

  default:
     ShowGroups();
     break;
}

Link to comment
Share on other sites

×
×
  • Create New...