SunQuest
 
           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:
Free Web 2.0 Code Generator! Generate data entry 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 September 2nd, 2002, 04:33 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
Question need help calling an id from db

I've been out of this for a while and I need help getting started again. I am trying to create a page that lists newsletters from a db by thier perspective dates of creation, then these will then be choices to view. The page displays a list that will grow as teachers create more newsletters.

I used one of Ben's tutorials to create the newsletter creation pages, just a big address book changed into text boxes, but everything in that tutorial was posted to self and not displayed to view on a new page. here is my code for the newsletterview page:

PHP Code:
<?php
$db 
mysql_connect "localhost""username""password");
mysql_select_db("database"$db);
$result mysql_query("SELECT * FROM newsletterkaren",$db); 
printf("Newsletter: %s<br>\n"mysql_result($result,0,"date"));
  
/* here is where I need some help. I want viewers to click on 
a date (link) and then get taken to that newsletter via. the id.  
The db has a unique id for each new newsletter... how do I code
 this to be a link ( and each additional newsletter created ) and 
call the db for its id ..? */ 
 
?>


On top of this, I need to be able to post each newsletter to a new page.  Here is the code for the newsletter creation page:

<?PHP 
session_start
();
session_destroy();
?>
<html><title>Newsletter</title> 
<body bgcolor="#CCCCCC">
<div align="left"><a href="http://www.aquariancharterschool.com/teacherspages/mskarenspage.html">Back 
  to Ms. Karen's Class</a><br>
</div>
<div align="center"> <font size="4"><b>Ms. Karen's Newletter Maker</b></font></div>
<p><a href="http://www.aquariancharterschool.com"><br>
  Back to Ms. Karen's Master Page </a></p>
<p>This is a plain but easy to use newsletter form. Edit current or old newsletters 
  by clicking on newsletter names, also delete newsletters by clicking the delete 
  button next to the corresponding newsletter.</p>
<h2><font size="3">Old/ Current Newsletters</font></h2>
<?php
$db 
= @mysql_connect("localhost""site""password"); 
mysql_select_db("database",$db); 
if (
$submit) { 
// here if no ID then adding else we're editing 
if ($id) { 
$sql "UPDATE newsletterkaren 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 newsletterkaren (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 newsletterkaren 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 newsletterkaren",$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 newsletterkaren 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="text1" wrap cols=100 rows=5><?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><?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><?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><?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 

?>



The only errors I am getting are from the list page for the newsletters. It is funny, the second page here will allow me to add and edit the newsletters, but they display on the same page...I want them to have their own pages...

Thank you for any help.

Edit: Please use the correct syntaxing, and please read the rules before posting

Edit2: Broke that gigantic, table braking sentence in half.
__________________
bow wow!

Last edited by ejbe99 : September 2nd, 2002 at 01:27 PM.

Reply With Quote
  #2  
Old September 3rd, 2002, 11:24 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
I am happy to reply to my own string : )

Well, I got it to work. I realize this is not a chat room, that real answers spin and weave their way around, but I was hoping to get some help. I may not have been making myself clear. I wanted to display items ( dates ) in a table as links to their respective newsletters. It worked, although only in Internet Explorer, not Netscape....does anyone know how to change code for Netscape users?

Reply With Quote
  #3  
Old September 4th, 2002, 01:25 AM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
firstly, dont display all your script, only the bits your having trouble with. whos going to read though all that code?

anyway what part of this code is giving you trouble?

Reply With Quote
  #4  
Old September 4th, 2002, 01:44 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
Just need help with Newscape

I got my links to work, now I just need to make my php pages to funciton with Netscape. Where can I go to read about this? It seems like none of my code works on pages that call from my db.

This forum and site is looking fantastic by the way.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > need help calling an id from db


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


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

Iron Speed




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