Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > PHP
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 08-20-2004, 05:27 PM   #1 (permalink)
jjfletch
Registered User
 
Join Date: Aug 2004
Posts: 1
jjfletch is on a distinguished road
Question [RESOLVED]

Hi,

I'm hoping someone here can help me.

I have a database that has several entries per user. What I want to do is to:

1) Create a dropdown menu whose options consist of each journal entry date for that particular user, and

2) Once one of the dates is selected from the dropdown menu, I'd like to display the entry associated with that particular date.

I've managed to create the dropdown menu (code for retrieve.php pasted below):




<?php

require_once ('../includes/config.inc');
$page_title = 'View Your Journal Entries';
include ('../includes/header2.html');

?>

<script language="JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>

<div id="mainarea">
<table width="700" height="400" border="1" bordercolor="#999999" bgcolor="#FFFFFF" cellpadding="10">
<tr><td valign="top"><h1>Your Journal Entries</h1>

<form action = "retrieve2.php" Method = "POST">
<select name="selObj" onChange="MM_jumpMenu('parent',selObj,0)">
<option selected>Select an Entry</option>

<?php

if (!isset($_SESSION['user_id'])) {

header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "../index.php");
ob_end_clean();
exit();

} else {

$uid = ($_SESSION['user_id']);
$fn = ($_SESSION['first_name']);
}

require_once ('../../../files/mysql_connect.php');

$query = mysql_query("SELECT * FROM entries WHERE user_id='$uid' ORDER BY 'journal_DATE' DESC");
while($row = mysql_fetch_array($query)) {
//notice the change in the url bellow
print '<option value="retrieve2.php?action=journal_DATE='.$row["journal_DATE"].'">'.$row["journal_DATE"];
print '</option>';
}

mysql_close();
?>
</td></tr>
<tr><td class="style1" valign="top"><a href="create.php">Create another entry</a>
</td></tr></table>
<?php
include ('../includes/footer2.html');
?>


What I can't figure out is how to achieve goal #2.

I know there's problems with the code (retrieve2.php) below, but can anyone tell me how to fix it? Thanks so much!



<?php

require_once ('../includes/config.inc');
$page_title = 'View Your Journal Entries';
include ('../includes/header2.html');

?>

<?php
if (!isset($_SESSION['user_id'])) {

header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "../../index.php");
ob_end_clean();
exit();

} else {

$uid = ($_SESSION['user_id']);
$fn = ($_SESSION['first_name']);
}

if (isset($_POST['selObj'])) {

require_once ('../../../files/mysql_connect.php');
$query = "SELECT journal_entry FROM entries WHERE user_id='$uid' AND journal_DATE={$_POST['selObj']}";
$result = mysql_query ($query);
while($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
echo "{$row['journal_entry']}";
}}

?>

__________________

Last edited by jjfletch : 08-20-2004 at 07:03 PM.
jjfletch is offline   Reply With Quote
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
EMERGENCY: Dynamic form processing DavH27 PHP 8 10-27-2004 07:52 PM
dynamic allocation..urgent help needed!!! kashif Standard C, C++ 4 04-21-2003 08:50 AM


All times are GMT -8. The time now is 11:07 PM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle