Web Hosting Talk







View Full Version : Help a noob please!


Knight_
04-18-2003, 11:25 PM
Hi all, i hope someone can help a real newbie (me :D ) to solve a problem.

I am building a site and the guy i'm doing the job for, asked me if he could be able to update the news page automatically without asking for my help everytime.

He's not able to use dreamweaver (i built the site using the v.4) and so i was thinking if there would be a way to use some programming features to create a log in screen with username and pwd for him, and let him compile the news page online directly from the site, and have it update dinamically. :confused:

This would avoid the necessity of modifying the page offline with dw and then upload it (he's neither an expert of ftp uploading, so i wanted to save him LOTS of troubles) but unfortunately i don't know the way of doing a thing like this.

Other problem (but a minor one) is that i would like the latest 3 news to appear in the homepage, and all the archive of the old news at the "news" page.

This would need that everytime a new headline is added, it goes in the homepage with the other 2 latest news, while the third one moves in the news page.

I don't know if i explained myself enough, the 1st problem is the more "urgent", the second one i can work it out in a second time.

I thank in advance all the people who will help me to solve this problem, pls if you can't do the whole thing for me (i suppose it's asking for too much) at least give me some advice on which programs/languages/stuff i need to study to work it out by myself.

THANKS!

Alphawolf
04-18-2003, 11:48 PM
I would look at using PHP & MySQL. They are both easy to learn and the price is right.

It is pretty simple then to create a login page that has an admin interface where the client can add news items, click submit and it updates the DB.

On the home page then, you would simply need to query the DB and display the first 3 records.

Don't forget you also need a way for your client to "Edit" and probably "Delete" news stories as well. If he/she were to add a news story, submit it and then find an error, he/she would want to edit the story. This could also be done using the same interface.

A good place to get started for PHP is Evil Walrus (http://www.evilwalrus.com)
They have scripts you can download and then modify to suite your info.

Good luck!!

Saeven
04-18-2003, 11:49 PM
If you go to my mud page, I have a news gizmo at http://www.saeven.net/sx/news.php

The entries are added by typing the news into a box and hitting submit. No edit features or anything, but it might set you on your way. Here's the code for news.php as seen:


<html>
<head>
<title>SaevenX News</title>
</head>
<body bgcolor="#000000" text="#CCCCCC" link="#CCCCCC" vlink="#990000" alink="#FF0000">
<div align="center">
<p><img src="http://saeven.net/images/logo.gif"></p>
<p>SaevenX, The Dark Sky Project</p>
<p>&nbsp;</p>
<p><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">[ <a href="news_1.htm">old
news</a> ] [ <a href="news.php">new news</a> ]</font></p>
<br><br>
</div>

<?php

$connection = mysql_connect("xxxx", "xxxx", "xxxx");

if ( !$connection ){
echo mysql_errno().": ".mysql_error();
exit;
}

mysql_select_db( "xxxx", $connection );
$res = mysql_query( "SELECT * FROM news_entries ORDER BY date DESC", $connection );
$numRows = mysql_num_rows ($res);

for( $i = 0 ; $i < $numRows ; $i++ ){
echo "<p><font face=\"Arial, Helvetica, sans-serif\"><font color=\"#FFFFFF\"><b>".mysql_result( $res, $i, 'date')."</b></font><br>".
"<blockuote>".mysql_result( $res, $i, 'entry').
"</blockquote></font></p>";
}

mysql_close( $connection );

?>
</body>
</html>


And then to enter the news edits, this is the code for that page:


<html>
<head>
<title>Add News Entry</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php
if( isset( $change ) ){
if( isset( $entry ) ){
$connection = mysql_connect("xxxx", "xxxx", "xxxx");

if ( !$connection ){
echo mysql_errno().": ".mysql_error();
exit;
}

mysql_select_db( "xxxx", $connection );

if ( !mysql_query( "INSERT INTO news_entries VALUES( NOW() , \"$entry\" )" ) ){
echo mysql_errno().": ".mysql_error();
exit;
}

mysql_close( $connection );
}
}
?>

<body>
<p><img src="saeveni.gif" width="378" height="131"></p>
<form name="form1" method="post" action="add_news.php">
<brbr>
<p> <font size="-1" face="Verdana, Arial, Helvetica, sans-serif">News Entry</font>
<font size="-2" face="Verdana, Arial, Helvetica, sans-serif">(can insert html)</font><br>
<textarea name="entry" cols="80" rows="10"></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Add News">
<input type="hidden" name="change" value="1">
</p>
</form>
</body>
</html>


It's basic as hell, but it's all I needed. Thought it might help you. The schema for the database is as follows:


#
# Table structure for table `news_entries`
#

CREATE TABLE news_entries (
date date default NULL,
entry tinytext
) TYPE=MyISAM;



Cheers.

Knight_
04-18-2003, 11:54 PM
Thanks a lot man, i'll go and browse the site you told me, and try to figure it out! :)

Your help was really appreciated, maybe i'll be back with some more questions when i'll have already got a certain knowledge of PHP (i think i will need some more help in a few days... hehe).
See you then! :)

PS: if someone else does have some more advices for me on this matter, please feel free to add your opinions, just don't think this thread close! ;)

Knight_
04-18-2003, 11:56 PM
Holy crap!
The post i made 2 seconds ago was to thank Alphawolf, as Saeven message didn't load in time for me to see it.

Thanks to Saeven too for his useful advice! i will study the code you gave me and try to implement it at best in my site! :D
Thanks a lot again!