rocky48 Posted May 7, 2012 Share Posted May 7, 2012 I am a programming novice. I aploigise if this is in the wrong forum, but the question embraces several languages. I have written a script in PHP that filters Greetings Verses of a certain type. What I want to do is pick one of the filtered verses, store its ID to be used in the script that prints out the verse. I am not sure that you can add a $Post to a form that has been output from MYSQL. Can anyone help? I would appreciate any ideas or alternative ways of achieving this. Here is the script: <?php include("loc_cverse_connect.php"); doDB(); //check for required info from the query string //verify the Event exists $verify_Event_sql = "SELECT ID, Event_Type FROM Events WHERE ID = '".$_POST["Event_Type"]."'"; $verify_Event_res = mysqli_query($mysqli, $verify_Event_sql) or die(mysqli_error($mysqli)); //echo $_POST["Event_Type"]; if (mysqli_num_rows($verify_Event_res) < 1) { //this Event does not exist $display_block = "<p><em>You have selected an invalid Event.<br/> Please try again.</em></p>"; } else { //get the Event ID while ($Event_info = mysqli_fetch_array($verify_Event_res)) { $Event_ID = stripslashes($Event_info['ID']); $Event_Name = ($Event_info['Event_Type']); } //gather the Events $get_Event_sql = "SELECT Verses.ID AS versesID, Verses.Verse, Verses.Sub_Type, Verses.Event, Events.ID AS eventsID, Events.Event_Type, Event_Sub.ID AS event_SubID, Event_Sub.Event_Sub_Type FROM Verses LEFT JOIN Events ON Verses.Event = Events.ID LEFT JOIN Event_Sub ON Verses.Sub_Type = Event_Sub.ID WHERE Verses.Event = '".$_POST["Event_Type"]."' ORDER BY Verses.ID ASC"; $get_Event_res = mysqli_query($mysqli, $get_Event_sql) or die(mysqli_error($mysqli)); //create the display string $display_block = " <p> The Event Type is <b> '".$Event_Name."'</b> </p> <table width=\"70%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" > <tr> <th>ID</th> <th>VERSE</th> <th>MOOD/SUB TYPE</th> </tr>"; while ($Verse_info = mysqli_fetch_array($get_Event_res)) { $Verse_id = $Verse_info['versesID']; $Verse_text = nl2br(stripslashes($Verse_info['Verse'])); $Mood_info = $Verse_info['Event_Sub_Type']; //add to display $display_block .= " <tr> <td width=\"1%\" valign=\"top\">".$Verse_id."<br/></td> <td width=\"55%\" valign=\"top\">".$Verse_text."<br/></td> <td width=\"35%\" valign=\"top\">" .$Mood_info."<br/></td> </tr>"; } //free results mysqli_free_result($get_Event_res); mysqli_free_result($verify_Event_res); //close connection to MySQL mysqli_close($mysqli); //close up the table $display_block .= "</table>"; } ?> <html> <head> <title> List of Verses</title> </head> <body BGCOLOR="#87CEEB"> <h1>Verses</h1> <FORM METHOD="LINK" ACTION="Size_Menu.html"> <INPUT TYPE="submit" VALUE="Go To Print Utility"> </FORM> <?php echo $display_block; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/262213-can-i-add-a-tick-box-to-a-form-output-from-mysql/ Share on other sites More sharing options...
BuildMyWeb Posted May 18, 2012 Share Posted May 18, 2012 yeah i think you already are aware... this is likely not the best forum. this is not an HTML issue. sorry i couldnt be of more help. Quote Link to comment https://forums.phpfreaks.com/topic/262213-can-i-add-a-tick-box-to-a-form-output-from-mysql/#findComment-1346500 Share on other sites More sharing options...
LLLLLLL Posted May 21, 2012 Share Posted May 21, 2012 What is wrong with what you have here? Does it work? Quote Link to comment https://forums.phpfreaks.com/topic/262213-can-i-add-a-tick-box-to-a-form-output-from-mysql/#findComment-1347353 Share on other sites More sharing options...
Solution rocky48 Posted May 31, 2012 Author Solution Share Posted May 31, 2012 Hi Yes this does work, but I am trying to make it more user friendly by eliminating some of the user input. It has been suggested elsewhere that I can use href, but I have not figured out how to do this yet. Does any one know how long a POST is stored, as if I get the hef to work it will need to survive until i have run another html script, before the value is used in a php script? Quote Link to comment https://forums.phpfreaks.com/topic/262213-can-i-add-a-tick-box-to-a-form-output-from-mysql/#findComment-1350114 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.