Form Tools
Using GET to display five specific entries on my website - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17)
+--- Thread: Using GET to display five specific entries on my website (/showthread.php?tid=1291)



Using GET to display five specific entries on my website - alexh - May 10th, 2011

Here's my next project, and I'm looking for input on how to do it:

I've created a form, and would like to do display five of the form entries on an html page.

My idea is that I will create a php page that will pull the specific fields from five entries, and format the fields with CSS/HTML, to display them the way I want.

I would like a user to be able to log in and select which entries display, and which do not... maybe with a checkbox.

So I would imagine I would need to write a page that would pretty much say 'if that checkbox is checked, then show on this page.. in this format'. That php page would then be used as php-include on the main page of our website.

Is that even possible?

If so, does anyone have some example code I could use that at least displays form fields on a php page? I looked at the tutorial but couldn't get it to work.

Thanks!
Alex


RE: Using GET to display five specific entries on my website - alexh - May 12th, 2011

So here is what I have figured out so far. I set up the form with formtools. I created an additional field that is a checkbox. The checkbox is not on the form, just editable from the backend when editing the results in formtools.

I then created a php page with the following attached code. Basically it says that if a certain field is equal to "1" (the checkbox), then show the data. (In other words, when the checkbox is checked, the data appears on the below page) The problem is, I'd like it to display each set of data in a different html table.. not as another row in the table.

Any ideas?

PHP Code:
<html>
<
body>
<?
php
$username
="USERNAME";
$password="PASSWORD";
$database="DATABASE";

mysql_connect(localhost,$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM ft_form_12 WHERE col_24='1'";
// $query="SELECT * FROM ft_form_12";
// SELECT * FROM ft_form_12 WHERE col_24='1'
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();
?>
<table border="0" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif">Value1</font></th>
<th><font face="Arial, Helvetica, sans-serif">Value2</font></th>
<th><font face="Arial, Helvetica, sans-serif">Value3</font></th>
<th><font face="Arial, Helvetica, sans-serif">Value4</font></th>
<th><font face="Arial, Helvetica, sans-serif">Value5</font></th>
</tr>

<?php
$i
=0;
while (
$i $num) {

$f1=mysql_result($result,$i,"col_1");
$f2=mysql_result($result,$i,"col_2");
$f3=mysql_result($result,$i,"col_3");
$f4=mysql_result($result,$i,"col_4");
$f5=mysql_result($result,$i,"col_5");
?>

<tr>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f1?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f2?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f3?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f4?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><?php echo $f5?></font></td>
</tr>

<?php
$i
++;
}
?>
</table>
</body>
</html>