General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old May 14th, 2002, 01:16 PM
littleblackdog littleblackdog is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Anchorage
Posts: 118 littleblackdog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Smile please help with online newsletter

This is an online newsletter form that teachers can use to fill in text boxes in a form and post to a view page that parents can read online. I also want to add a function for parents to view the other newsletters from the a main newsletter page with a list of the older letters.
So there would be one page for the teacher only to create the page. One page that displays all the pages ( links ). And one page to view the pages.
The problems I have encountered: ( most of the code is adapted from Ben Rowe's basic PHP tutorial )
1. I can't recall the TEXTAREA boxes when trying to edit from the create newsletter page, although they write to the db fine.
2. The view newsletter page does not currently work. At one time it did, but I added more functions and now it is messed.
3. I need the view page to recall one page at a time, according to the choice made at the ( not yet created ) link page.
4. The create page needs to be able to edit the newletters, and it can not, just can't get the textboxes to show data.

Please, any suggestions to create the view page or the on how to streamline the view page would be appreciated.

Here is the code:
Create Newsletter Page:
<?PHP
session_start();
session_destroy();
?>
<html><title>Newsletter</title>
<body bgcolor="#CCCCCC">
<a href="Mr.Jacksscienceview1.php">
<h1><font size="3">View Newsletter</font></h1>
</a><div align="left"><a href="http://www.aquariancharterschool.com/Mr.%20Jack.htm">Back
to Mr.Jack's Class</a><br>
</div>
<div align="center"> <font size="4"><b>Mr. Jack's Newletter Maker</b></font></div>
<a href="http://www.aquariancharterschool.com/a/jacksmasterpage.html"><br>
Back to Mr. Jack's Master Page </a>
<h2><font size="3">Current Newsletters</font></h2>
<?php
$db = @mysql_connect("localhost", "alaska", "password");
mysql_select_db("alaska_mydb",$db);
if ($submit) {
// here if no ID then adding else we're editing
if ($id) {
$sql = "UPDATE newsletter SET month='$month',date='$date', title1='$title1',text1='$text1',title2='$title2',t ext2='$text2',title3='$title3',text3='$text3',titl e4='$title4',text4='$text4' WHERE id=$id";
} else {
$sql = "INSERT INTO newsletter (month,date,title1,text1,title2,text2,title3,text3 ,title4,text4) VALUES ('$month','$date','$title1','$text1','$title2','$t ext2','$title3','$text3','$title4','$text4')";
}
// run SQL against the DB
$result = mysql_query($sql);
echo "Record updated/edited!<p>";
} elseif ($delete)
{
// delete a record
$sql = "DELETE FROM newsletter WHERE id=$id";
$result = mysql_query($sql);
echo "$sql Record deleted!<p>";
} else {
// this part happens if we don't press submit
if (!$id) {
// print the list if there is not editing
$result = mysql_query("SELECT * FROM newsletter",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href=\"%s?id=%s\">%s</a> \n", $PHP_SELF, $myrow["id"], $myrow["date"]);
printf("<a href=\"%s?id=%s&delete=yes\">(DELETE)</a><br>", $PHP_SELF, $myrow["id"]);
}
}
?>
<form method="post" action="<?PHP echo $PHP_SELF?>">
<?PHP
if ($id) {
// editing so select a record
$sql = "SELECT * FROM newsletter WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$id = $myrow["id"];
$month = $myrow["month"];
$date = $myrow["date"];
$title1 = $myrow["title1"];
$text1 = $myrow["text1"];
$title2 = $myrow["title2"];
$text2 = $myrow["text2"];
$title3 = $myrow["title3"];
$text3 = $myrow["text3"];
$title4 = $myrow["title4"];
$text4 = $myrow["text4"];
// print the id for editing
?>
<input type=hidden name="id" value="<?PHP echo $id ?>">
<?PHP
}
?>
Month:
<input type="Text" name="month" value="<?PHP echo $month ?>"><br>
Date:<input type="Text" name="date" value="<?PHP echo $date ?>"><br>
Title 1:<input type="Text" name="title1" value="<?PHP echo $title1 ?>"><br>
Text 1:<br><TEXTAREA name="test1" wrap cols=100 rows=5 value="<?PHP echo $text1 ?>"></TEXTAREA><br>
Title 2:<input type="Text" name="title2" value="<?PHP echo $title2 ?>"><br>
Text 2:<br><TEXTAREA name="text2" wrap cols=100 rows=5 value="<?PHP echo $text2 ?>"></TEXTAREA><br>
Title 3:<input type="Text" name="title3" value="<?PHP echo $title3 ?>"><br>
Text 3:<br><TEXTAREA name="text3" wrap cols=100 rows=5 value="<?PHP echo $text3 ?>"></TEXTAREA><br>
Title 4:<input type="Text" name="title4" value="<?PHP echo $title4 ?>"><br>
Text 4:<br><TEXTAREA name="text4" wrap cols=100 rows=5 value="<?PHP echo $text4 ?>"></TEXTAREA><br>
<p>
<input type="Submit" name="submit" value="Enter information">
<a href="<?PHP echo $PHP_SELF?>">Clear and Refresh</a>
</form>
<?PHP
}
?>
</body>
</html>







Here is the ( non working view page ):
This one I am trying to have linked to by the link page, so parents can call up older and current newsletters. Much of this code was taken from a guest book, and with the guest book, it just wrote the entire db, not selecting just an id or specific row.

<html>
<title>Newsletter</title>
<body bgcolor="#FFFF99">
<table width="726" border="0" bgcolor="#CCCCCC" bordercolor="#CCCCCC">
<tr>
<td width="57" rowspan="3"><img src="ecardpics/aquarlogo.gif" width="100" height="100"></td>
<td colspan="2" bgcolor="#CCCCCC">
<div align="center"><font size="3"><b><font size="4">Mr. Jack's and Ms. Judy's Class</font></b></font></div>
</td>
<td width="67" rowspan="3"><img src="ecardpics/aquarlogo.gif" width="100" height="100"></td>
</tr>
<tr>
<td colspan="2" bgcolor="#CCCCCC">
<div align="center"><font size="3"><b><font size="5">Aquarian Online Newsletter</font></b></font></div>
</td>
</tr>
<tr>
<td width="304" bgcolor="#CCCCCC" height="46" valign="bottom" align="center"><a href="http://www.aquariancharterschool.com/Mr.%20Jack.htm">Back
to Mr. Jack's Class</a> </td>
<td width="294" bgcolor="#CCCCCC" height="46" align="center" valign="bottom"><br>
<a href="http://www.aquariancharterschool.com">Back to Aquarian</a> </td>
</tr>
</table>
<hr>
<p align="center">

<?php
$db = mysql_connect ( "localhost", "alaska", "password");
mysql_select_db("alaska_mydb", $db);
$result = mysql_query("SELECT * FROM newsletter", $db);
if ( $myrow = mysql_fetch_array($result))
{
echo "<p align=center>";
echo "<table width='400' border='0'>\n";
do {
printf ("<tr><td width='200'><div align=center><font size='4'><b>%s</b></font></div></td></tr><br><tr><td width='200'><div align=center><b>%s</b></div></td></tr>\n",
$myrow[month],$myrow[date]);

}
while ($myrow = mysql_fetch_array($result));
echo "</p>";
echo "</tabel>\n";
}
else {
echo " Sorry, no records were found.";
}

$result = mysql_query("SELECT * FROM newsletter", $db);
if ( $myrow = mysql_fetch_array($result))
{
echo "<p align=center>";
echo "<table width='650' border='0'>\n";
do {
printf ("<tr><td width='300'valign='top'wrap>%s</td><td width='50'>%s</td><td width='300' valign='top' wrap>%s</td></tr><br>\n",
$myrow[title1], $myrow[blank], $myrow[title2]);
}
while ($myrow = mysql_fetch_array($result));
echo "</p>";
echo "</tabel>\n";
}
else {
echo " Sorry, no records were found.";
}

$result = mysql_query("SELECT * FROM newsletter", $db);
if ( $myrow = mysql_fetch_array($result))
{
echo "<p align=center>";
echo "<table width='650' border='0'>\n";
printf ("<tr><td width='300'valign='top'wrap>%s</td><td width='50'>%s</td><td width='300' valign='top' wrap>%s</td></tr><br>\n",
$myrow[text1], $myrow[blank], $myrow[text2]);

}
while ($myrow = mysql_fetch_array($result));
echo "</p>";
echo "</tabel>\n";
}
else {
echo " Sorry, no records were found.";
}
?>
</p>
</body>
</html>
__________________
bow wow!

Reply With Quote
  #2  
Old May 14th, 2002, 11:54 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
OK, first your editor.

you have

Text 4:<br><TEXTAREA name="text4" wrap cols=100 rows=5 value="<?PHP echo $text4 ?>"></TEXTAREA><br>

your thinking that a text area has the same properties as a input tag, change it to this

Text 4:<br><TEXTAREA name="text4" wrap cols=100 rows=5><?PHP echo $text4 ?></TEXTAREA><br>

that should bring up the data in the text area now.

ill have to help you with the other page in a few hours, as im at work. but that should get you started.

Reply With Quote
  #3  
Old May 15th, 2002, 04:37 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
can you give me an example of what your trying to do with the 2nd page????

basically you want a list like some thing like

free books
parent-teacher interview
blah
blah


then when a parent clicks on a title, it brings up the full details???


i think this is what your trying to do

Reply With Quote
  #4  
Old May 15th, 2002, 11:45 AM
littleblackdog littleblackdog is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: Anchorage
Posts: 118 littleblackdog User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Thanks Ben, you were right on...

No sooner had I posted the script for the first page, with the bad TEXTAREA tag, when I figured out that it did not need the "value=" statement. Lots of trial and error to get there but I have that working. Thanks.

The second page is just a view that pulls data out the the db in the shape of a newsletter with neat colums and rows, thats all.

Can you give me sample code to have links in php that refer to rows in the data base so I can have a list of links, and call up db info. from the link?

What about the ability to have users choose the size and color of text or backgrounds, any idea where I can find examples of code like that?

Thanks for all your help.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > please help with online newsletter


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway