Jump to content

How do you add a form checkbox within a table?


rocky48

Recommended Posts

I am using MYSQL to filter the database and the output that is generated is output as a table.

I want the user to choose one of the rows on the table and the result be posted for use in a later program.

I have tried the following  but all it produces is the text in the box:

//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>
<th>Link</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>
	<td width=\"9%\" valign=\"top\">  <INPUT TYPE="Radio" NAME="ID" VALUE=".$Verse_id." /></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>";
}

Can anyone suggest the correct way to allow the script to work as I wish?

Link to comment
Share on other sites

Discovered some errors with quotes so line should be:

		<td width=\"9%\" valign=\"top\"> <INPUT TYPE='Radio' NAME='ID' VALUE='".$Verse_id."'/></td>

 

Now I get Radio button, but how do I Submit this POST.

Tried to enclose table within a FORM but get a T_STRING Error.

Not shure where the form tags need to go?

Link to comment
Share on other sites

try this read my notes

<?php //never forget the opening and closing tags
//create the display string
$display_block = "
<p> The Event Type is <b> 
 ".$Event_Name."</b> </p> //changed the ".
<table width=\"70%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"#87CEEB\" >
<tr>
<th>ID</th>
<th>VERSE</th>
<th>MOOD/SUB TYPE</th>
<th>Link</th>
</tr>";
// where is your sql query
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>
	<td width=\"9%\" valign=\"top\"> 
         <form action=\"youraction.php\"".method=."\"post\">
         <input type=\"Radio\" name=\"ID\" value=\"".$Verse_id."\" />
         <input name=\"submit\" type=\"submit\" />
      </td> 
	</tr>";// you forgot to escape the " in the input and inpu changed to small laters
}
// now you can catch the values from the input by either post if you want to store in a database or get if you want to use it as an action to do //some other staff.
//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>";
}
?>

Link to comment
Share on other sites

Thanks for your input!

I am getting a syntax error unexpected '=' on line 64.

Why has the method got a dot before it?

Without the dot it gives unexpected T_STRING on line 64.

Also surely the form tag should be closed some where!

 

Link to comment
Share on other sites

I am getting a syntax error unexpected '=' on line 64.

Without the dot it gives unexpected T_STRING on line 64.

Also surely the form tag should be closed some where!

 

<?php
"<p> The Event Type is <b> 
".$Event_Name."</b> </p> //changed the ".
<table width=\"70%\" 

 

There's a period there that doesn't need to be there. it's erroring out at the table width property.  Notice the color? 

 

Why has the method got a dot before it?

Because it's appending the forthcoming string to the previous value.

Link to comment
Share on other sites

Hi to you both!

 

Found why it was erroring- ".method=." should have been ".method."=

However script runs OK but the ID posted does not seem to be remembered in the final script.

After this script called showtype.php an HTML script runs(VInput.html) to get the rest of the variables required for the final script (Prnpdf.php) which outputs a PDF file.

Here are the 2 scripts:

VInput.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- Generated by Avanquest Technology v:8.0. For information please visit: http://www.avanquestusa.com/ -->
<html lang="en">
<head>
<title> Verses - A5 Portrait </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css;">
<link rel="stylesheet" href="1066mk2_g.css" type="text/css" media="screen,projection,print">	<!--// Document Style //-->
<link rel="stylesheet" href="Vinput_p.css" type="text/css" media="screen,projection,print">	<!--// Page Style //-->
<script src="cverses_g.js" type="text/javascript"></script>	<!--// Document Script //-->
</head>

<body BGCOLOR="#00ff66">

<span id="e11"></span>
<span id="e12"></span>
<span id="e13"></span>
<span id="e14"></span>
<span id="e15"></span>
<span id="e16"></span>
<div id="e3" class="navigation">
	<a id="a3" class="navigation" href="index.html" target="Vframe5>index">
	Home</a>
</div>
<div id="e4" class="navigation">
	<a id="a4" class="navigation" href="1066mk2_002.htm" target="Vframe5>1066mk2_002">
	Links</a>
</div>
<div id="e5" class="navigation">
	<a id="a5" class="navigation" href="1066mk2_003.htm" target="Vframe5>1066mk2_003">
	Techniques</a>
</div>
<div id="e6" class="navigation">
	<a id="a16" class="navigation" href="topiclist_frame.html" target="Vframe5>topiclist_frame">
	Forum</a>
</div>
<div id="e7" class="navigation">
	<a id="a7" class="navigation" href="1066mk2_004.htm" target="Vframe5>1066mk2_004">
	Contact Us</a>
</div>
<div id="e8" class="navigation">
	<a id="a8" class="navigation" href="1066mk2_006.htm" target="Vframe5>1066mk2_006">
	Gallery</a>
</div>

<div id="e31" class="cc03">

	 <form NAME=Lists action="Prnpdf.php" method="post">
   	<Table>
            <tr>
                <th>Card Size</th>
            </tr>
            
                <td>
                    <select name="CSize">
  <option value="A5P"> A5 Portrait</option>
  <option value="A5L"> A5 Landscape</option>
  <option value="A5PS"> A5 Portrait (single)</option>
  <option value="A6P"> A6 Portrait</option>
  <option value="A6L"> A6 Landscape</option>
  <option value="A6PS"> A6 Portrait (Single)</option>
  <option value="7x5P"> 7" x 5" Portrait</option>
  <option value="7x5L"> 7" x 5" Landscape</option>
  <option value="6x4P"> 6" x 4" Portrait</option>
  <option value="6x4L"> 6" x 4" Landscape</option>
  <option value="DLP"> DL Portrait</option>
  <option value="DLL"> DL Landscape</option>
  <option value="120SQP"> 120mm Square Portrait</option>
  <option value="120SQL"> 120mm Square Landscape</option>
  <option value="125SQP"> 125mm Square Portrait</option>
  <option value="125SQL"> 125mm Square Landscape</option>
  <option value="130SQP"> 130mm Square Portrait</option>
  <option value="130SQL"> 130mm Square Landscape</option>
  <option value="135SQP"> 135mm Square Portrait</option>
  <option value="135SQL"> 135mm Square Landscape</option>
  <option value="145SQP"> 145mm Square Portrait</option>
  <option value="145SQL"> 145mm Square Landscape</option>
  <option value="150SQP"> 150mm Square Portrait</option>
  <option value="150SQL"> 150mm Square Landscape</option>
  <option value="160SQS"> 160mm Square (Single)</option>
  <option value="190SQS"> 190mm Square (Single)</option>
  <option value="200SQS"> 200mm Square (Single)</option>
  <option value="210SQS"> 210mm Square (Single)</option>  
                    </select>
<!--		<p><strong>Input Verse ID:</strong><br/> <input type="text" size="10" name="ID"/></p> -->
	<p><strong>Input Distance from top in mm:</strong><br/> <input type="text" size="10" name="Top"/></p>
	<p><strong>Input Font size in points:</strong><br/> <input type="text" size="10" name="font"/></p>
	<p><strong>Check only ONE Tick Box in each section!</strong></p>
	<p><strong>Text Colour</strong></p>
	<input type="checkbox" name="color" value="000000000" /> Black<br />
	<input type="checkbox" name="color" value="255215000" /> Gold<br />
	<input type="checkbox" name="color" value="192192192" /> Silver<br />
	<input type="checkbox" name="color" value="255000000" /> Red<br />
	<input type="checkbox" name="color" value="000255000" /> Green<br />
	<input type="checkbox" name="color" value="000000255" /> Blue<br /><br />

	<p><strong>Text Font</strong></p>
	<input type="checkbox" name="fontface" value="French Script MT" /> French Script MT<br />
	<input type="checkbox" name="fontface" value="Batavia" /> Batavia <br />
	<input type="checkbox" name="fontface" value="Algerian" /> Algerian <br />
	<input type="checkbox" name="fontface" value="Bladerunner" /> Bladerunner <br />
	<input type="checkbox" name="fontface" value="Brush Script" /> Brush Script<br />
	<input type="checkbox" name="fontface" value="Helterskelter" /> Helterskelter<br />	
	<input type="checkbox" name="fontface" value="Justice" /> Justice<br />
	<input type="checkbox" name="fontface" value="Magneto" /> Magneto<br />
	<input type="checkbox" name="fontface" value="Old English" /> Old English<br />
	<input type="checkbox" name="fontface" value="Sneakerhead Outline" /> Sneakerhead Outline<br />
	<input type="checkbox" name="fontface" value="Trendy" /> Trendy<br />
	<input type="checkbox" name="fontface" value="Vladimir Script" /> Vladimir Script<br />


</div>	
<div id="e32" class="cc03">	
	<p><strong>Border Images (PORTRAIT)</strong></p>
	<input type="checkbox" name="image" value="empty.jpg" /> No Border<br />
	<input type="checkbox" name="image" value="Border10p.jpg" /> Rose Border<br />
	<input type="checkbox" name="image" value="Border2p.jpg" /> Chequered Border<br />
	<input type="checkbox" name="image" value="Border11p.jpg" /> Ribbon Border<br />
	<input type="checkbox" name="image" value="Border5p.jpg" /> Yellow Border<br />
	<input type="checkbox" name="image" value="Corner2p.jpg" /> Leaf Corners<br />
	<input type="checkbox" name="image" value="corner1p.jpg" /> Laurel Corners<br /><br />
	<p><strong>Border Images (LANDSCAPE)</strong></p>
	<input type="checkbox" name="image" value="empty.jpg" /> No Border<br />
	<input type="checkbox" name="image" value="Border10l.jpg" /> Rose Border<br />
	<input type="checkbox" name="image" value="Border2l.jpg" /> Chequered Border<br />
	<input type="checkbox" name="image" value="Border11l.jpg" /> Ribbon Border<br />
	<input type="checkbox" name="image" value="Border5l.jpg" /> Yellow Border<br />
	<input type="checkbox" name="image" value="Corner2l.jpg" /> Leaf Corners<br />
	<input type="checkbox" name="image" value="corner1l.jpg" /> Laurel Corners<br /><br />

	<input type="submit" value="Submit"/>
	</form>
</div>
</body>
</html>

Prnpdf.php

<?php
include("loc_cverse_connect.php");
doDB();


//Get the Card Variables
$Get_Size_sql = "SELECT * FROM `csize` WHERE `Size` ='".$_POST["CSize"]."'";
$Get_Size_res =  mysqli_query($mysqli, $Get_Size_sql) or die(mysqli_error($mysqli));

//$sql = "SELECT * FROM `csize` WHERE Size=\"A5P\"";

if (mysqli_num_rows($Get_Size_res) < 1) {
//this Card does not exist
$display_block = "You have selected an invalid Card size.
Please try again.";
} else {
//get the Event ID
while ($Size_info = mysqli_fetch_array($Get_Size_res)) {
	$BoxX = stripslashes($Size_info['BoxX']);
	$Cellw = stripslashes($Size_info['Cellw']);
	$Cellh = stripslashes($Size_info['Cellh']);
	$SizeI = stripslashes($Size_info['Size']);
	$SID = stripslashes($Size_info['SID']);
	$floatx = stripslashes($Size_info['floatx']);
	$floaty = stripslashes($Size_info['floaty']);
	$floatw = stripslashes($Size_info['floatw']);
	$floath = stripslashes($Size_info['floath']);
	$ort = stripslashes($Size_info['ort']);
}
	//create the display string
	$display_block = "$ort";
}
//verify the Event exists
$Get_Verse_sql = "SELECT ID, Event, Sub_Type, Verse FROM Verses WHERE ID = '".$_POST["ID"]."'";
$Get_Verse_res =  mysqli_query($mysqli, $Get_Verse_sql) or die(mysqli_error($mysqli));

//check the variable is being passed through
if (isset($_POST['ID'])){
echo 'ID is '.$_POST['ID'];
}



if (mysqli_num_rows($Get_Verse_res) < 1) {
//this Event does not exist
$display_block = "You have selected an invalid Event.
Please try again.";
} else {
//get the Event ID
while ($Verse_info = mysqli_fetch_array($Get_Verse_res)) {
	$Verse = stripslashes($Verse_info['Verse']);
}
	//create the display string
$display_block = "$Verse";

//free results
mysqli_free_result($Get_Verse_res);
mysqli_free_result($Get_Size_res);
//close connection to MySQL
mysqli_close($mysqli);
}



require('fpdf.php');

class PDF extends FPDF
{
var $B;
var $I;
var $U;
var $HREF;

function PDF($orientation='P', $unit='mm', $size='A4')
{
    // Call parent constructor
    $this->FPDF($orientation,$unit,$size);
    // Initialization
    $this->B = 0;
    $this->I = 0;
    $this->U = 0;
    $this->HREF = '';
}



function SetStyle($tag, $enable)
{
    // Modify style and select corresponding font
    $this->$tag += ($enable ? 1 : -1);
    $style = '';
    foreach(array('B', 'I', 'U') as $s)
    {
        if($this->$s>0)
            $style .= $s;
    }
    $this->SetFont('',$style);
}

}

$color = $_POST[color];
$r = substr($color,0,3);
$g = substr($color,3,3);
$b = substr($color,6,3);
$image=$_POST[image];

$pdf = new PDF($ort,'mm','A4');
$pdf->AddPage();
$pdf->AddFont('French Script MT','','frscript.php');
$pdf->AddFont('Batavia','','Batavia_.php');
$pdf->AddFont('Algerian','','Alger.php');
$pdf->AddFont('Bladerunner','','BLADRMF_.php');
$pdf->AddFont('Brush Script','','BRUSHSCI.php');
$pdf->AddFont('Helterskelter','','Helte___.php');
$pdf->AddFont('Justice','','Justice_.php');
$pdf->AddFont('Magneto','','MAGNETOB.php');
$pdf->AddFont('Old English','','OldEngl.php');
$pdf->AddFont('Sneakerhead Outline','','Sneabo__.php');
$pdf->AddFont('Trendy','','Trendy__.php');
$pdf->AddFont('Vladimir Script','','VLADIMIR.php');
$pdf->SetTextColor($r,$g,$b);
$pdf->SetFont($_POST[fontface],'',$_POST[font]);
$pdf->SetXY($BoxX, $_POST[Top]);
$pdf->Image($image,$floatx,$floaty,$floatw,$floath,jpg,'');
$pdf->MultiCell($Cellw,$Cellh,$display_block,'' ,'C');
$pdf->SetFont('');
$pdf->Output('verse.pdf','D');
?>

Why does it not remember the post?

Link to comment
Share on other sites

Hi

Button in the correct place now, but the POST is not being passed to the final script (Prnpdf.php).

Does the Submit in the next script (VInput.html) clear any POST's previously sumitted.

I am nearly there now!

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.

Guest
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.