Jump to content

Having problem with table targeting thingy!


ztealmax

Recommended Posts

hi having some trouble with this targeted includes...

This is part of the code what it does is that this line [code]<?php print($value["name"]);?>[/code] gets the names needed a flat text file now i want to open that in the targeted table below..

How do i do that the correct way? :)


[code]get the file to open![/code]
[code] <?php
if(isset($_GET['target'])){
include($_GET['target'].".php?text=news/".print($value['name']));

} else {
echo "&nbsp;";
}
?>[/code]



//CHeers
*Im as noob as it gets*
To try and explain better:

at my index i have this:
[b]index.php[/b]
[code]<?php
if(isset($_GET['target'])){
include($_GET['target'].".php");
} else {
echo "&nbsp;";
}
?>[/code]

and here is the file that lists all news:
[b]news.php[/b]
[code]<?php
$this = $PHP_SELF;
$dir  = $DOCUMENT_ROOT."news/";

$files = opendir($dir);
$file_list = array();
$file_sort = array();

if(empty($sort))$sort="date";
if(empty($r)) $r=1;

$cnt = 1;

    while ($file = readdir($files))
{
$full_path = $dir."/".$file;
if(!is_dir($full_path))
{
$ext = explode(".",$file);
$i=count($ext);
if($i>1)$file_details["ext"] = strtolower($ext[$i-1]);
$file_details["name"] = $ext[0];
$file_details["date"] = filectime($full_path);
$file_list[$cnt] = $file_details;

$key = strtolower($file_details[$sort]);
$file_sort[$cnt] = $key;

$cnt++;
}
}

if($r)arsort($file_sort);
else asort($file_sort);


?>


<table width="465" border="0" cellpadding="3" cellspacing="0" class="smallblacktext">
  <tr>
    <td width="174"><?php print($this);?><?php print(!$r);?><? echo lan_11 ?></td>
    <td width="141"><?php print($this);?><?php print(!$r);?><? echo lan_12 ?></td>
  </tr>
  <tr bgcolor="#0033CC">
    <td height="3" colspan="5"> </td>
  </tr>
<?php
while(list($key, $value)=each($file_sort))
{
$value = $file_list[$key];
?>
  <tr>
    <td width="174"><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=read"><?php print($value["name"]);?></a></td>
    <td width="141"><?php print(date("Y/m/d H:i",$value["date"]));?></td>
  </tr>
<?php
}
?>
</table>[/code]

Now what i want to happend is i want this line to open selected document in the targeted area:
[code]><a href="<?=$_SERVER['PHP_SELF']?>?target=read"><?php print($value["name"]);?></a>[/code]

as i do with my menu code:
[b]menu.php[/b]
[code]<table>
<tr>
<td><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=welcome"><? echo lan_2 ?></a></td>
<td><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=news"><? echo lan_3 ?></a></td>
<td><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=links"><? echo lan_4 ?></a></td>
<td><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=forum"><? echo lan_5 ?></a></td>
<td><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=downloads"><? echo lan_6 ?></a></td>
<td><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=members"><? echo lan_7 ?></a></td>
</tr></table>
[/code]

Is this possible? if so how i tried some variants but cant get it to work!

Any help is much helpfull :)

Thank you
//Martin
I tried this

in index.php
[code]
<?php
if(isset($_GET['target'])){
include($_GET['target'].".php?text=news/".print($value["name"]));
} else {
echo "&nbsp;";
}
?>
[/code]

and this on news.php
[code]<?php
$this = $PHP_SELF;
$dir  = $DOCUMENT_ROOT."news/";

$files = opendir($dir);
$file_list = array();
$file_sort = array();

if(empty($sort))$sort="date";
if(empty($r)) $r=1;

$cnt = 1;

    while ($file = readdir($files))
{
$full_path = $dir."/".$file;
if(!is_dir($full_path))
{
$ext = explode(".",$file);
$i=count($ext);
if($i>1)$file_details["ext"] = strtolower($ext[$i-1]);
$file_details["name"] = $ext[0];
$file_details["date"] = filectime($full_path);
$file_list[$cnt] = $file_details;

$key = strtolower($file_details[$sort]);
$file_sort[$cnt] = $key;

$cnt++;
}
}

if($r)arsort($file_sort);
else asort($file_sort);


?>


<table width="465" border="0" cellpadding="3" cellspacing="0" class="smallblacktext">
  <tr>
    <td width="174"><?php print($this);?><?php print(!$r);?><? echo lan_11 ?></td>
    <td width="141"><?php print($this);?><?php print(!$r);?><? echo lan_12 ?></td>
  </tr>
  <tr bgcolor="#0033CC">
    <td height="3" colspan="5"> </td>
  </tr>
<?php
while(list($key, $value)=each($file_sort))
{
$value = $file_list[$key];
?>
  <tr>
    <td width="174"><img src='<? echo BULLET ?>' />
<a href="<?=$_SERVER['PHP_SELF']?>?target=read"><?php print($value["name"]);?></a></td>
    <td width="141"><?php print(date("Y/m/d H:i",$value["date"]));?></td>
  </tr>
<?php
}
?>
</table>
[/code]

Cant see what im doing wrong with this code... :(

guess its this row im having problems on:
[code]<a href="<?=$_SERVER['PHP_SELF']?>?target=read"><?php print($value["name"]);?></a></td>[/code]
well i have , check all the posting ;)

anyways this:
[code]<a href="<?=$_SERVER['PHP_SELF']?>?target=read"><?php print($value["name"]);?></a>[/code]
i would want to use with:
[code]<?php
if(isset($_GET['target'])){
include($_GET['target'].".php?text=news/".print($value["name"]));
} else {
echo "&nbsp;";
}
?>[/code]

as i use this menu system:
[code]<table>
<tr>
<td><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=welcome"><? echo lan_2 ?></a></td>
<td><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=news"><? echo lan_3 ?></a></td>
<td><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=links"><? echo lan_4 ?></a></td>
<td><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=forum"><? echo lan_5 ?></a></td>
<td><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=downloads"><? echo lan_6 ?></a></td>
<td><img src='<? echo BULLET ?>' /><a href="<?=$_SERVER['PHP_SELF']?>?target=members"><? echo lan_7 ?></a></td>
</tr></table>
[/code]

but i cant get it to work

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.