Click to See Complete Forum and Search --> : News admin page
aoeguy
11-03-2003, 11:15 AM
I am making a news admin page and have 90% finished. Only thing missing is the most important thing :lol:
I cant add the news to the news page, atm it has the ending .htm
news.htm is news page
news_admin/index.php login
news_admin/add.php is where you enter what you want to type and the icon.
news_admin/view.php is where you preview what you saw, when you click a link it should add that to news.htm (should it be news.php?)
I know how to open a file, but it overwrites the whole file - dont know how not to - so how can I add in the code that was generated in add.php and sent to view.php in to news.htm under the title etc.
Long question, I cant explain it much better :(
The News table in view.php is from line 14 under the comment
<!-- News Table -->
Stephen
In your fopen (http://us2.php.net/manual/en/function.fopen.php), you could use "a" for your mode. This will cause new data to be appended to the file. Other than that, you could read the file into a variable, concatenate your new content, and then re-write the entire file.
aoeguy
11-03-2003, 12:22 PM
The table code in a variable wont work, it just displays it.
Then how do I insert the code UNDER the title?
You lost me. Perhaps you'd better explain a bit more clearly.
aoeguy
11-03-2003, 12:31 PM
Ok, I will show you with code:
News page header, info etc
<html>
<head>
<meta http-equiv="newscontent-Type" content="text/html; charset=windows-1252">
<meta http-equiv="newscontent-Language" content="en-us">
<meta name="Author" content="Bandit_Raider">
<meta name="Publisher" content="Bandit_Raider">
<meta name="Copyright" content="GNB Clan">
<meta name="Keywords" content="aoe,aom,clans,bandit,gnb,fun,age of mythology,age of empires,bandit_raider,eso,bandit_chris,eso,stephen,aoeguy">
<meta name="Description" content="English Age of Mythology Clan website. We only play on ESO (Ensemble Studios Online) and accept any player skill levels.">
<meta name="Page-topic" content="Games, Age of Mythology">
<meta name="Audience" content="All">
<meta name="newscontent-language" content="EN">
<meta name="Page-type" content="games">
<meta name="Robots" content="INDEX,FOLLOW">
<base target="_self">
<LINK REL="StyleSheet" HREF="aompage.css" TYPE="text/css">
</head>
<body text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" background="desert_bg.JPG" bgproperties="fixed">
<h3 align="center"><font color="#FFFFFF" face="Arial">Bandits Clan - News</font></h3>
Now the news comes underneath. The new news needs to be added here!
The whole news table from view.php should be saved into a variable or something so I can add it here.
If you want to see what I mean by table look here (http://bandits.clans.cc/news.htm)
The easiest way to do this would probably be to add a comment where you want the content added. When you go to add the content, just split at the comment, add your new content between the split and add the comment back in (so it knows where to place new content).
Also, are you aware of the fact that when images are disabled the page looks like a big buch of white, as the text color and background color are the same? Best fix that, at least, though I'd also recommend validating (http://validator.w3.org/) your code.
aoeguy
11-03-2003, 12:47 PM
Never heard of disabling images :confused:
I have got I comment there
<!-- News -->
I dont know how to split that.
Try this:
list ($header, $footer) = split("<!-- News -->", $page_contents);
aoeguy
11-03-2003, 12:54 PM
Dont quite understand that code, where do you set those variables and I suppose its no prob where to add that code into.
$header and $footer are the variables that will containt the content once it is split - $header the part above the comment and $footer the part below. $page_contents is the variable that contains the code for the page you are trying to add the content to.
aoeguy
11-03-2003, 01:25 PM
View.php
<head>
<title>News Admin</title>
<LINK REL="StyleSheet" HREF="../aompage.css" TYPE="text/css">
</head>
<body background="../aom/bg/greek.jpg" topmargin="0" leftmargin="0" text="#FFFFFF">
<?php
$text = $_POST["text"];
$date = $_POST["date"];
$title = $_POST["title"];
$dir = $_POST["dir"];
$img = $_POST["img"];?>
<!-- News Table -->
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="89" class="newscontent">
<tr>
<td width="40" class="newstitle" height="12">
<p><img border="0" width="40" height="40" src="<?php echo $dir,$img;?>"></p>
</td>
<td width="731" class="newstitle" height="12"><font face="arial"> <?php echo "$title</font>";?></td>
<td width="40" class="newstitle" height="12">
<p><img border="0" src="<?php echo $dir,$img;?>" width="40" height="40"></p>
</td>
</tr>
<tr>
<td width="799" class height="57" colspan="3"><font face="Arial" size="1"><?php echo "
Posted on $date by $user";?></font>
<dl>
<dd>
<p><font face="Arial"><?php echo $text;?></font></dd>
</dl>
</td>
</tr>
<tr>
<td width="799" class height="25" colspan="3">
<p align="center"><a href="#top"><font color="#FFFFFF" face="Arial">Back
to Top</font></a></td>
</tr>
</table>
<p> </p>
<?php
$file = fopen ("../news.htm",a);
rewind ($file);
list ($header, $footer) = split("<!-- News -->", $page_contents);
?>
.......
Havnt got further yet, anything wrong with it? If you have time could you send the code at the bottom so I can just insert it?
Thanks
aoeguy
11-04-2003, 06:00 AM
When I add the table into a variable it just displays HTML and not PHP Variable:
<table border="0" cellpadding="0" cellspacing="0" width="100%" height="89" class="newscontent">
<tr>
<td width="40" class="newstitle" height="12">
<p><img border="0" width="40" height="40" src="<?php echo $dir,$img;?>"></p>
</td>
<td width="731" class="newstitle" height="12"><font face="arial"> <?php echo "$title</font>";?></td>
<td width="40" class="newstitle" height="12">
<p><img border="0" src="<?php echo $dir,$img;?>" width="40" height="40"></p>
</td>
</tr>
<tr>
<td width="799" class height="57" colspan="3"><font face="Arial" size="1"><?php echo "
Posted on $date by $user";?></font>
<dl>
<dd>
<p><font face="Arial"><?php echo $text;?></font></dd>
</dl>
</td>
</tr>
<tr>
<td width="799" class height="25" colspan="3">
<p align="center"><a href="#top"><font color="#FFFFFF" face="Arial">Back
to Top</font></a></td>
</tr>
</table>
<p> </p>
This is the code in the page now (without table):
<head>
<title>News Admin</title>
<LINK REL="StyleSheet" HREF="../aompage.css" TYPE="text/css">
</head>
<body background="../aom/bg/greek.jpg" topmargin="0" leftmargin="0" text="#FFFFFF">
<?php
$text = $_POST["text"];
$date = $_POST["date"];
$title = $_POST["title"];
$dir = $_POST["dir"];
$img = $_POST["img"];
?>
<!-- Content -->
Table here --->
<!--/Content -->
<?php
$file = fopen ("../news.htm",w);
fwrite ($file,'');
?>
I will give you the files too, it is better to look at.