Jump to content


Photo

Drop Box - Select = Show that Page Not Working? (HELP)


  • Please log in to reply
6 replies to this topic

#1 mark s

mark s
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 04 March 2006 - 06:23 PM

I'm not that new to forms but this one is driving me mad.
I have previously used a confirm page to pass the varibles i need.


I should have asked / posted earlier but i really didnt think it would cause me such a headache.
The more i read up on it the more confused and re-directed i become.
If anyone can help it would be appreciated very much.

How do i get the value from the drop box to hook up on my function?

I have a Drop Box which lists the dates of Newsletters.
These are called Dynamically from my Database.
1st Jan
1st Feb
1st March .....ect....

That works fine :) (After fun and games).

-------------------------------
I have 2 Functions running with in the script.
If no action keyword is present, just list the last entry.
If action keyword "newsletter" go to the $theId of Date Selected.
Which would then show the relevent Newsletter.
Which is pulled and displayed from my database against the date.
Best way i could explane it to be honnest.
But its not working.
I cant get the value from the drop box to carry over so to speak.

--------------------------------

The Following code checks when the page is loaded / refreshed.
I have all my database querys runing fine.
So if i visit this page the first time "default" is invoked.
And if my url includes "http://www.blarblar/...ewsletter&id=4"
Then the news letter with the ID of 4 would be displayed.

Functions are actioned as follows.
<?php
 if (empty($_GET['action'])) $_GET['action'] = "";
 switch($_GET['action']) {
 case "newsletter":
 requested_newsletter();
  break;
  default: 
  list_records();
  break;
}

The following code is my form / dropbox.

<?php
$results= mysql_query("SELECT cw_02, cw_00  FROM `newsletter` WHERE `cw_06` = '1' ORDER BY `cw_00` DESC "); 
$id = "cw_00";
$idname = "cw_02"; 
echo mysql_error(); 

// following line may be wrong, as its been changed 100 times.
echo "<form action=\"?action=newsletter&id=$theId\" method=\"post\" name=\"form1\" target=\"_self\" id=\"form1\">
      <select name=\"select\">";
      
if (mysql_Numrows($results)>0)                            //if there are records in the fields
{ 
  $numrows=mysql_NumRows($results);                       //count them
  $x=0; 
  while ($x<$numrows){   //loop through the records
    $theId=mysql_result($results,$x,$id);                 //place each record in the variable everytime we loop
    $theName=mysql_result($results,$x,$idname);
    echo "<option value=\"$theId\">$theName</option>\n";  //and place it in the select
    $x++;
  }
} 
      
echo       "</select>";
echo      "<input type=\"submit\" name=\"Submit\" value=\"Submit\" />";
echo    "</form>" ?>

But when i use the submit button,
i only get what ever is in the Action= without the value of the drop box ??
[a href=\"http://www.blarblar/index2.php?action=newsletter&id=\" target=\"_blank\"]http://www.blarblar/index2.php?action=newsletter&id=[/a]
Which works with the "Newsletter Function" as there are no results.
As the $theId has failed to be carried over.

Ive read so much about the dynamic listboxes the creation, but using the vaules,
isnt covered in enough detail for me to understand where i'm going wrong?
i have become totaly lost and confused now. Any guidence woud be appreciated.

How do i get the value from the drop box to hook up on my function?

#2 Humpty

Humpty
  • Members
  • PipPipPip
  • Advanced Member
  • 132 posts

Posted 04 March 2006 - 09:18 PM

Even going straight to the page does nothing:
[a href=\"http://www.blarblar/index2.php\" target=\"_blank\"]http://www.blarblar/index2.php[/a]

Just set all lines as remark // to start with and ensure that the file is in the right location.

At this point it seems like nothing to do with php.

[a href=\"http://www.blarblar/\" target=\"_blank\"]http://www.blarblar/[/a] gets a 404 as well


did you leave the .com or .net or whatevere off on purpose?


- Humpty
  #> Where does the light go when it goes out?

#3 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 04 March 2006 - 09:54 PM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]i only get what ever is in the Action= without the value of the drop box ??[/quote]
Considering that the Action= is never changed by the form, that's not really surprising.

The value passed from the drop box is $_POST['select']
Legend has it that reading the manual never killed anyone.
My site

#4 Humpty

Humpty
  • Members
  • PipPipPip
  • Advanced Member
  • 132 posts

Posted 04 March 2006 - 09:59 PM

Yeah I understand that, however after reading a few tutorials on it I was lead to believe that if you used the malto as an action for the form that the form's contents was in the email.

Not one of them specified any different, (will check it out though), maybe by adding body=$_POST['nameofitem'] in the 'bdy' variable of the mailto it will work.

(unconfirmed as of yet)
- Humpty
  #> Where does the light go when it goes out?

#5 mark s

mark s
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 04 March 2006 - 11:07 PM

The url i used was just that an example.
It does visit the correct page (Same page) its just the $ID does not drop in.
So my Newsletter function can not look up the db to display the correct record.

Ive been playing around and have got it a little closer?

Whats happening now,
And it is, that now when i hit the submit button,
it shows the record that was previously selected??

Example.

Jan =1 "Click the Submit" = Shows Newest record (25)
Aug = 7 "Click the Submit" = Shows Record 1 as above.
Dec = 12 "Click the Submit" = Shows Record 7 as above.
or

If i select the same record twice it drops in the second time??

It may be easier to read if i dont use the code button.

-------------------------------------------
function catlist(){
$sql = mysql_query("SELECT cw_02, cw_00 FROM `cw_newsletter` WHERE `cw_06` = '1' ORDER BY `cw_00` DESC ");

echo "<select name=\"cw_00\">";

while(list($cw_02, $cw_00)=mysql_fetch_array($sql)){
$view = date("M Y", strtotime($cw_02));

echo "<option value=\"$cw_00\">$cw_00 $view</option>";
}
echo "</select>";

}

echo"<form action=\"?action=newsletter&id=$cw_00\" method=\"post\" name=\"form\" id=\"form\">";
// The Form:

catlist();

echo "<input type=\"Submit\" Value=\"Submit\">
</form>";
?>
---------------------------------------------------

Im thinking now my problem may be with the $GET "action"......

Shall plod on...

Thanks for any help offered :)

I read also, today and im going off what i read, is that Netscape N understands the
changing of the Action function to mailto....
But IE does not?
Dont quote me on it as ive just read so much.

#6 Humpty

Humpty
  • Members
  • PipPipPip
  • Advanced Member
  • 132 posts

Posted 04 March 2006 - 11:39 PM

Try adding +1 to your data.

That may assist. the count of an item, (records too), may = 11, but they are numbered 0-10 (that makes 11).
- Humpty
  #> Where does the light go when it goes out?

#7 mark s

mark s
  • Members
  • PipPip
  • Member
  • 26 posts

Posted 04 March 2006 - 11:48 PM

My problem at the mo is,
that i dont fully understand how to use the drop list value and use it?

What i can do :-

Make a Dynamic Drop Box that reads from the database.
Show the relevent months and also read a value ( 1 to 25).

So my drop box is looking correct.

============================================
HELP WITH PLEASE

So then using the info..
I create a submit button.
And it does nothing :(
So i change the form action to = the page url and it now does somthing.

What i need it to do on submit is to take the value from the drop list.
And use it.

This is why i cant belive the head ache its giving me,
it doesnt seem that difficult on paper so to speak...

I think i will have to build it up from fresh again.
And look for more examples... to work from.

I know this may seem like a small task but i'm hoping to use what
i learn about this process on much larger dropboxes in the future.
Hence why i dont just list everything manually in the drop box.

Any help or examples i can work from would be appreciated,
as you can tell i'm going Nuuuuuuuuuuuuuuuuts.....




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users