Jump to content

Can I add a tick box to a form output from MYSQL?

Go to solution Solved by rocky48,

Recommended Posts

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:


//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
ON Verses.Event = Events.ID
ON Verses.Sub_Type = Event_Sub.ID
WHERE Verses.Event = '".$_POST["Event_Type"]."' 

$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\" >
<th>MOOD/SUB TYPE</th>

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 .= "
	<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>

//free results

//close connection to MySQL

//close up the table
$display_block .= "</table>";


<title> List of Verses</title>
<body BGCOLOR="#87CEEB">
<FORM METHOD="LINK" ACTION="Size_Menu.html">
<INPUT TYPE="submit" VALUE="Go To Print Utility">
<?php echo $display_block; ?>

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • Solution



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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.