mark s Posted March 4, 2006 Share Posted March 4, 2006 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.[b][i]How do i get the value from the drop box to hook up on my function?[/i][/b]I have a Drop Box which lists the dates of Newsletters.These are called Dynamically from my Database.1st Jan1st Feb1st 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 [b]$theId[/b] 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/index2.php?action=newsletter&id=4"Then the news letter with the ID of 4 would be displayed.Functions are actioned as follows.[code]<?php if (empty($_GET['action'])) $_GET['action'] = ""; switch($_GET['action']) { case "newsletter": requested_newsletter(); break; default: list_records(); break;}[/code]The following code is my form / dropbox.[code]<?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>" ?>[/code]But when i use the submit button,i only get what ever is in the [b]Action=[/b] 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 [b]$theId[/b] 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.[b][i]How do i get the value from the drop box to hook up on my function?[/i][/b] Quote Link to comment https://forums.phpfreaks.com/topic/4096-drop-box-select-show-that-page-not-working-help/ Share on other sites More sharing options...
Humpty Posted March 4, 2006 Share Posted March 4, 2006 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 welldid you leave the .com or .net or whatevere off on purpose? Quote Link to comment https://forums.phpfreaks.com/topic/4096-drop-box-select-show-that-page-not-working-help/#findComment-14256 Share on other sites More sharing options...
AndyB Posted March 4, 2006 Share Posted March 4, 2006 [!--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'] Quote Link to comment https://forums.phpfreaks.com/topic/4096-drop-box-select-show-that-page-not-working-help/#findComment-14266 Share on other sites More sharing options...
Humpty Posted March 4, 2006 Share Posted March 4, 2006 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) Quote Link to comment https://forums.phpfreaks.com/topic/4096-drop-box-select-show-that-page-not-working-help/#findComment-14268 Share on other sites More sharing options...
mark s Posted March 4, 2006 Author Share Posted March 4, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/4096-drop-box-select-show-that-page-not-working-help/#findComment-14284 Share on other sites More sharing options...
Humpty Posted March 4, 2006 Share Posted March 4, 2006 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). Quote Link to comment https://forums.phpfreaks.com/topic/4096-drop-box-select-show-that-page-not-working-help/#findComment-14292 Share on other sites More sharing options...
mark s Posted March 4, 2006 Author Share Posted March 4, 2006 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 PLEASESo 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 whati 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..... Quote Link to comment https://forums.phpfreaks.com/topic/4096-drop-box-select-show-that-page-not-working-help/#findComment-14294 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.