I would like my form to run some additional queries ones the data has been collected and inserted into the database. I don't know much anything about PHP, so how can I do this? Could someone give me an example of how to run just a really simple select query *after* the data is inserted into the form? Would I add this code on the processor.php form or another one?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
</HEAD>
<BODY bgColor=#eeeeee>
<CENTER>
<TABLE cellSpacing=20>
<TBODY>
<TR>
<TD><!---this is the top navigation bar--->
<TABLE cellSpacing="0" cellPadding="1" bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="1" bgColor="#cccccc" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="3" bgColor="white" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="1" bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="5" width="510" bgColor="#ff9900" border="0">
<TBODY>
<TR>
<TD>
<P><B>phpFormGenerator</B></P></TD>
<TD vAlign="bottom" align="right">
<TABLE cellSpacing="0" cellPadding="1"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE height="20" cellSpacing="0" cellPadding="1"
bgColor="#ffcc00" border="0">
<TBODY>
<TR>
<TD class="small"> [ <A
href="http://phpformgen.sourceforge.net/">home</A>
] [<A
href="https://sourceforge.net/project/showfiles.php?group_id=45605">update</A>] [<A
href="http://sourceforge.net/docman/?group_id=45605">support</A>] [<A
href="mailto:musawir@ali.tf">contact</A>]
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><!---this is the bottom section where all the content goes--->
<TABLE cellSpacing="0" cellPadding="1" bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="1" bgColor="#cccccc" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="3" bgColor="white" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="1" bgColor="#333333"
border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="3" width="510"
bgColor="#ff9900" border="0">
<TBODY>
<TR>
<TD vAlign="top"><!---Side Navigation and Links--->
<TABLE>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="1"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="2" width="100"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD class="small" align="middle"><FONT
color="#ffffff"><B>quick links</B></FONT>
</TD></TR>
<TR>
<TD class="small" bgColor="#ffcc00">- <A
href="http://sourceforge.net/projects/phpformgen/">project
web</A><BR />- <A
href="http://www.sourceforge.net/">sourceforge</A><BR />-
<A
href="http://www.linux.com/">linux.com</A><BR />-
<A href="http://www.php.net/">php.net</A><BR />-
<A
href="http://www.mysql.com/">mysql.com</A><BR />-
<A
href="http://www.apache.org/">apache.org</A><BR /></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><BR />
<TABLE cellSpacing="0" cellPadding="1"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="2" width="100"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD class="small" align="middle"><FONT
color="#ffffff"><B>powered by</B></FONT>
</TD></TR>
<TR>
<TD class="small"
bgColor="#ffcc00">h4x0rs.us<BR /></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><BR />
<TABLE cellSpacing="0" cellPadding="1"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="2" width="100"
bgColor="#cccccc" border="0">
<TBODY>
<TR>
<TD class="small" align="middle"
bgColor="#333333"><B><FONT color="white">wise
words</FONT></B> </TD></TR>
<TR>
<TD class="small" bgColor="#eeeeee">What is the
difference between genius and stupidity? Genius
has limits. - Albert Einstein.
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
<TD align="right" rowSpan="2"><!---Item boxes for daily news events or whatever you want to talk about, i have included three.--->
<TABLE>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="1"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding="2" width="400" bgColor="#ffcc00" border="0">
<TBODY>
<TR>
<TD bgColor="#333333"><font color="#FFFFFF"><b>
Administration Portal</b></font></TD>
<TD class="small" align="right"
bgColor="#333333"><FONT color="#ffffff">v2.10</FONT>
</TD></TR>
<TR>
<TD class="small" colSpan="2">This is your portal
for maintaining your form usage. If you have
used the 'mysql' or 'file-based' database
option of the program, you can take advantage of
this portal which will let you view all the
records filled in through your form.<p> </p>
<p class="small">
<!- Put code here ->
<?php
/* Define Global Variables*/
$db_host = "myhost";$db_user = "me";$db_pass = "password";$db_name = "test";$db_table = "testdata";
$debug=0;
# GRAB THE VARIABLES FROM THE URL
$sort_col = $_GET;
if (($file_db != 1)&&($db == 1)) {
echo "Using MySQL Database:<br /><br />\n\n";
if ($GLOBALS == "") {
if($debug){echo "Sort Column is blank. Value = '".$sort_col."'<br />\n\n";}
$order="";
$result=get_SQL_data();
if(!$result) die("Get raw SQL data failed.");
display_SQL_data();
}
else {
$order=get_SQL_column_name();
if($debug){echo "Sort Column is ".$order."<br />\n\n";}
$result=get_SQL_data();
if(!$result) die("Get SQL data to sort failed.");
display_SQL_data();
}
}
elseif (($file_db == 1)&&($db != 1)) {
echo "Using File-based Database:<br /><br />\n";
if ($GLOBALS == "") {
$order="";
$result=get_file_data();
if(!$result) die("Get raw data failed.");
display_file_data();
}
else {
$order=$GLOBALS;
$result=get_file_data();
if(!$result) die("Get data to sort failed.");
display_file_data();
}
}
else {
echo "Sorry. In order to use the administration portal you must use the MySQL or File-based Database option.\n\n";
}
function get_file_data() {
/* Open File as read only. */
$raw_result=fopen($GLOBALS,'rb') or die ("<br />Could not open the data file.");
$line1=0;
$i=0;
$char="|";
while (!feof($raw_result)) {
$temp_rec = fgets($raw_result,4096);
$temp_rec=trim($temp_rec);
if ($line1 == 0) {
$temp_rec="id$char$temp_rec";
$columns = explode("|",$temp_rec);
$temp_col = sizeof($columns);
$line1++;
}
if ($temp_rec != "") {
if ($i>0) {
$temp_rec="$i$char$temp_rec";
}
$records = "$temp_rec";
$i++;
}
}
for($j=0;$j<$i;$j++) {
$holder = explode("|",$records);
for ($k=0;$k<sizeof($holder);$k++) {
$myresult = $holder;
}
}
if ($GLOBALS) {
$myresult=sortByColumn($myresult, $GLOBALS);
}
return $myresult;
}
function display_file_data() {
/*Get the number of columns */
$i=0;
$myresult=$GLOBALS;
$mysort_col=$GLOBALS;
$file_db=$GLOBALS;
if(!$myresult) die("No Data to display.");
/* Number of columns in Data file*/
$tmp= mydata_num_fields($i);
while ($i < $tmp) {
$meta = mydata_fetch_field($i);
$columns = $meta;
$i++;
}
/*Creat the table and display the data */
/*Table Header */
echo "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" width=\"90%\">\n";
echo "<tr><td colspan=\"" . (sizeof($columns)+2) . "\">\n";
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" width=\"100%\">\n";
echo "<tr><td class=\"big\" bgcolor=\"#000000\" align=\"center\" valign=\"middle\">\n";
/* Normal Records Header*/
function mydata_num_fields() {
/* Get the number of columns from the data file array */
$myresult=$GLOBALS;
$num_columns=0;
while($myresult) {
$num_columns++;
}
return $num_columns;
}
function mydata_fetch_field($i) {
/* Get a single column value from the data file array */
$myresult=$GLOBALS;
$field=$myresult;
return $field;
}
function mydata_fetch_array() {
/* Get a row of data from the data file array */
$myresult=$GLOBALS;
$row=$myresult;
return $row;
}
function get_SQL_data() {
/* Get SQL Data. */
/* mySQL Table */
$myresult=$GLOBALS;
$myhostname=$GLOBALS;
$myusername=$GLOBALS;
$mypassword=$GLOBALS;
$mydbname=$GLOBALS;
$mytable=$GLOBALS;
$myorder=$GLOBALS;
$i = 0;
$db_con=mysql_connect($myhostname, $myusername, $mypassword) or die("Connetion to database failed!");
mysql_select_db($mydbname, $db_con);
if ($myorder == ""){
$query = "SELECT * FROM $mytable";
}
else {
$query = "SELECT * FROM $mytable ORDER BY $myorder";
}
$myresult = mysql_query($query, $db_con);
/* make sure data was retrieved */
if(!$myresult) die("Data Query Failed.");
if(!$myresult) die("Get_Data Function Failed.");
return $myresult;
}
function display_SQL_data() {
$i=0;
$myresult=$GLOBALS;
$mysort_col=$GLOBALS;
$file_db=$GLOBALS;
if(!$myresult) die("No Data to display.");
/* Number of columns in SQL*/
while ($i < mysql_num_fields($myresult)) {
$meta = mysql_fetch_field($myresult);
$columns = $meta->name;
$i++;
}
/*Creat the table and display the data */
/*Table Header */
echo "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" width=\"90%\">\n";
echo "<tr><td colspan=\"" . (sizeof($columns)+2) . "\">\n";
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" width=\"100%\">\n";
echo "<tr><td class=\"big\" bgcolor=\"#000000\" align=\"center\" valign=\"middle\">\n";
/* Normal Records Header*/
if ($mysort_col == ""){
echo "<font color=\"#ffffff\">Records Table</td></tr></table></td></tr><tr>\n";
}
/* Sorted Records Header*/
else {
echo "<font color=\"#ffffff\">Sorted Records Table</td></tr></table></td></tr><tr>\n";
}
/* Display Column Titles*/
I would like my form to run some additional queries ones the data has been collected and inserted into the database. I don't know much anything about PHP, so how can I do this? Could someone give me an example of how to run just a really simple select query *after* the data is inserted into the form? Would I add this code on the processor.php form or another one?
Thanks
File from an older version of the generator:
Save it to a php file, modify the /* Define Global Variables*/ then point your browser to it.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>phpFormGenerator v2.10 Admin Portal</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<STYLE>
P {
PADDING-LEFT: 8px; PADDING-RIGHT: 8px; FONT-SIZE: 12px; MARGIN: 10px; COLOR: #333333; LINE-HEIGHT: 18px; FONT-FAMILY: verdana, arial, "ms sans serif", sans-serif
}
.small {
PADDING-LEFT: 8px; PADDING-RIGHT: 8px; FONT-WEIGHT: normal; FONT-SIZE: 10px; COLOR: #333333; LINE-HEIGHT: 14px; FONT-FAMILY: verdana, arial, "ms sans serif", sans-serif
}
.big {
PADDING-LEFT: 8px; PADDING-RIGHT: 8px; FONT-SIZE: 14px; COLOR: #333333; LINE-HEIGHT: 14px; FONT-FAMILY: verdana, arial, "ms sans serif", sans-serif
}
TD {
FONT-SIZE: 12px; COLOR: #333333; FONT-FAMILY: verdana, arial, "ms sans serif", sans-serif
}
A:link {
FONT-WEIGHT: bold; COLOR: #FFFFFF; TEXT-DECORATION: none
}
A:visited {
FONT-WEIGHT: bold; COLOR: #EEEEEE; TEXT-DECORATION: none
}
A:active {
FONT-WEIGHT: bold; COLOR: #DDDDDD; TEXT-DECORATION: none
}
A:hover {
FONT-WEIGHT: bold; COLOR: #888888; TEXT-DECORATION: overline
}
INPUT {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 10px; PADDING-BOTTOM: 0px; COLOR: #333; PADDING-TOP: 0px; FONT-FAMILY: verdana, arial, sans-serif; BACKGROUND-COLOR: #eeeeee
}
TEXTAREA {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 10px; PADDING-BOTTOM: 0px; COLOR: #333; PADDING-TOP: 0px; FONT-FAMILY: verdana, arial, sans-serif; BACKGROUND-COLOR: #eeeeee
}
SELECT {
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 10px; PADDING-BOTTOM: 0px; COLOR: #333; PADDING-TOP: 0px; FONT-FAMILY: verdana, arial, sans-serif; BACKGROUND-COLOR: #eeeeee
}
INPUT.button {
BORDER-RIGHT: #999 2px outset; BORDER-TOP: #999 2px outset; BORDER-LEFT: #999 2px outset; BORDER-BOTTOM: #999 2px outset; BACKGROUND-COLOR: #ccc
}
</STYLE>
</HEAD>
<BODY bgColor=#eeeeee>
<CENTER>
<TABLE cellSpacing=20>
<TBODY>
<TR>
<TD><!---this is the top navigation bar--->
<TABLE cellSpacing="0" cellPadding="1" bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="1" bgColor="#cccccc" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="3" bgColor="white" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="1" bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="5" width="510" bgColor="#ff9900" border="0">
<TBODY>
<TR>
<TD>
<P><B>phpFormGenerator</B></P></TD>
<TD vAlign="bottom" align="right">
<TABLE cellSpacing="0" cellPadding="1"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE height="20" cellSpacing="0" cellPadding="1"
bgColor="#ffcc00" border="0">
<TBODY>
<TR>
<TD class="small"> [ <A
href="http://phpformgen.sourceforge.net/">home</A>
] [<A
href="https://sourceforge.net/project/showfiles.php?group_id=45605">update</A>] [<A
href="http://sourceforge.net/docman/?group_id=45605">support</A>] [<A
href="mailto:musawir@ali.tf">contact</A>]
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><!---this is the bottom section where all the content goes--->
<TABLE cellSpacing="0" cellPadding="1" bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="1" bgColor="#cccccc" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="3" bgColor="white" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="1" bgColor="#333333"
border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="3" width="510"
bgColor="#ff9900" border="0">
<TBODY>
<TR>
<TD vAlign="top"><!---Side Navigation and Links--->
<TABLE>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="1"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="2" width="100"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD class="small" align="middle"><FONT
color="#ffffff"><B>quick links</B></FONT>
</TD></TR>
<TR>
<TD class="small" bgColor="#ffcc00">- <A
href="http://sourceforge.net/projects/phpformgen/">project
web</A><BR />- <A
href="http://www.sourceforge.net/">sourceforge</A><BR />-
<A
href="http://www.linux.com/">linux.com</A><BR />-
<A href="http://www.php.net/">php.net</A><BR />-
<A
href="http://www.mysql.com/">mysql.com</A><BR />-
<A
href="http://www.apache.org/">apache.org</A><BR /></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><BR />
<TABLE cellSpacing="0" cellPadding="1"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="2" width="100"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD class="small" align="middle"><FONT
color="#ffffff"><B>powered by</B></FONT>
</TD></TR>
<TR>
<TD class="small"
bgColor="#ffcc00">h4x0rs.us<BR /></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR>
<TR>
<TD><BR />
<TABLE cellSpacing="0" cellPadding="1"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="2" width="100"
bgColor="#cccccc" border="0">
<TBODY>
<TR>
<TD class="small" align="middle"
bgColor="#333333"><B><FONT color="white">wise
words</FONT></B> </TD></TR>
<TR>
<TD class="small" bgColor="#eeeeee">What is the
difference between genius and stupidity? Genius
has limits. - Albert Einstein.
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD>
<TD align="right" rowSpan="2"><!---Item boxes for daily news events or whatever you want to talk about, i have included three.--->
<TABLE>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing="0" cellPadding="1"
bgColor="#333333" border="0">
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding="2" width="400" bgColor="#ffcc00" border="0">
<TBODY>
<TR>
<TD bgColor="#333333"><font color="#FFFFFF"><b>
Administration Portal</b></font></TD>
<TD class="small" align="right"
bgColor="#333333"><FONT color="#ffffff">v2.10</FONT>
</TD></TR>
<TR>
<TD class="small" colSpan="2">This is your portal
for maintaining your form usage. If you have
used the 'mysql' or 'file-based' database
option of the program, you can take advantage of
this portal which will let you view all the
records filled in through your form.<p> </p>
<p class="small">
<!- Put code here ->
<?php
/* Define Global Variables*/
$db_host = "myhost";$db_user = "me";$db_pass = "password";$db_name = "test";$db_table = "testdata";
$debug=0;
# GRAB THE VARIABLES FROM THE URL
$sort_col = $_GET;
if (($file_db != 1)&&($db == 1)) {
echo "Using MySQL Database:<br /><br />\n\n";
if ($GLOBALS == "") {
if($debug){echo "Sort Column is blank. Value = '".$sort_col."'<br />\n\n";}
$order="";
$result=get_SQL_data();
if(!$result) die("Get raw SQL data failed.");
display_SQL_data();
}
else {
$order=get_SQL_column_name();
if($debug){echo "Sort Column is ".$order."<br />\n\n";}
$result=get_SQL_data();
if(!$result) die("Get SQL data to sort failed.");
display_SQL_data();
}
}
elseif (($file_db == 1)&&($db != 1)) {
echo "Using File-based Database:<br /><br />\n";
if ($GLOBALS == "") {
$order="";
$result=get_file_data();
if(!$result) die("Get raw data failed.");
display_file_data();
}
else {
$order=$GLOBALS;
$result=get_file_data();
if(!$result) die("Get data to sort failed.");
display_file_data();
}
}
else {
echo "Sorry. In order to use the administration portal you must use the MySQL or File-based Database option.\n\n";
}
function get_file_data() {
/* Open File as read only. */
$raw_result=fopen($GLOBALS,'rb') or die ("<br />Could not open the data file.");
$line1=0;
$i=0;
$char="|";
while (!feof($raw_result)) {
$temp_rec = fgets($raw_result,4096);
$temp_rec=trim($temp_rec);
if ($line1 == 0) {
$temp_rec="id$char$temp_rec";
$columns = explode("|",$temp_rec);
$temp_col = sizeof($columns);
$line1++;
}
if ($temp_rec != "") {
if ($i>0) {
$temp_rec="$i$char$temp_rec";
}
$records = "$temp_rec";
$i++;
}
}
for($j=0;$j<$i;$j++) {
$holder = explode("|",$records);
for ($k=0;$k<sizeof($holder);$k++) {
$myresult = $holder;
}
}
if ($GLOBALS) {
$myresult=sortByColumn($myresult, $GLOBALS);
}
return $myresult;
}
function display_file_data() {
/*Get the number of columns */
$i=0;
$myresult=$GLOBALS;
$mysort_col=$GLOBALS;
$file_db=$GLOBALS;
if(!$myresult) die("No Data to display.");
/* Number of columns in Data file*/
$tmp= mydata_num_fields($i);
while ($i < $tmp) {
$meta = mydata_fetch_field($i);
$columns = $meta;
$i++;
}
/*Creat the table and display the data */
/*Table Header */
echo "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" width=\"90%\">\n";
echo "<tr><td colspan=\"" . (sizeof($columns)+2) . "\">\n";
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" width=\"100%\">\n";
echo "<tr><td class=\"big\" bgcolor=\"#000000\" align=\"center\" valign=\"middle\">\n";
/* Normal Records Header*/
echo "<font color=\"#ffffff\">Records Table</td></tr></table></td></tr><tr>\n";
/* Display Column Titles*/
/* Display Column Titles from Data file. */
for ($i=0;$i<sizeof($columns);$i++) {
echo "<td align='center' valign='middle'>\n";
echo "<table cellspacing='0' cellpadding='0' border='1' width='100%'>\n";
echo "<td class='small' bgcolor='#000000' align='center' valign='middle'>\n";
echo "<a href='index.php?sort_col=".$i."'><center><b>".$columns."</td>\n";
echo "</td></table></td>\n";
}
echo "<td class='small' bgcolor='#000000' colspan='2' align='center' valign='middle'><center>";
echo "<a href=\"printer_friendly_all.php\">Print All</a>";
/* Display Data File*/
$i=1;
while($myresult) {
echo "<tr>";
for ($k=0;$k<sizeof($columns);$k++) {
echo "<td class='small'><center>".$myresult."</td>";
}
echo "<td class='small' bgcolor='#000000' align='center' valign='middle'><center>";
if($file_db != 1) {
echo "<a href='delete_rec.php?id=".$myresult."'>delete</a></td>";
} else {
echo "<a href='delete_file_rec.php?id=".$myresult."'>delete</a></td>";
}
echo "<td class='small' bgcolor='#000000' align='center' valign='middle'><center>";
echo "<a href=\"printer_friendly.php?id=".$myresult."\">Print</a></td>";
$i++;
}
echo "<tr><td class='small' bgcolor='#000000' colspan=\"".(sizeof($columns)+2)."\" align='center' valign='middle'>";
echo "<center><a href=\"printer_friendly_all.php\">Print All</a>";
echo "</table>";
}
function sortByColumn($array2d, $col) {
/* Find Columns*/
$c=0;
while($array2d) { $c++; }
/* Find Rows*/
$r=0;
while($array2d) { $r++; }
// echo "<li>Rows: $r, Columns: $c";
/* Stuff First Row (preserve column titles)*/
for($cI=0;$cI<$c;$cI++) {
$array2d = $array2d;
// echo "<li>".$newArray2d."<br>";
}
/* Sort Routine*/
$start_row=1;
for($rI=$start_row;$rI<=$r-1;$rI++) {
for($cI=0;$cI<$c;$cI++) {
$tmpArray2d=$array2d;
}
$offset = $rI-1;
while(($offset >= $start_row)&&($array2d > $tmpArray2d)) {
for($cI=0;$cI<$c;$cI++) {
$array2d = $array2d;
}
$offset = $offset-1;
}
for($cI=0;$cI<$c;$cI++) {
$array2d = $tmpArray2d;
}
}
return $array2d;
}
function mydata_num_fields() {
/* Get the number of columns from the data file array */
$myresult=$GLOBALS;
$num_columns=0;
while($myresult) {
$num_columns++;
}
return $num_columns;
}
function mydata_fetch_field($i) {
/* Get a single column value from the data file array */
$myresult=$GLOBALS;
$field=$myresult;
return $field;
}
function mydata_fetch_array() {
/* Get a row of data from the data file array */
$myresult=$GLOBALS;
$row=$myresult;
return $row;
}
function get_SQL_column_name() {
/*Get Column Names */
$mysort_col=$GLOBALS;
$col_name="";
$j=0;
$myresult=get_SQL_data();
if(!$myresult) die("SQL Query results not aquired.");
while ($j < mysql_num_fields($myresult)) {
$meta = mysql_fetch_field($myresult);
$columns = $meta->name;
$j++;
}
for($i=0;$i<sizeof($columns);$i++) {
if ($i == $mysort_col) {
$col_name="$columns";
}
}
return $col_name;
}
function get_SQL_data() {
/* Get SQL Data. */
/* mySQL Table */
$myresult=$GLOBALS;
$myhostname=$GLOBALS;
$myusername=$GLOBALS;
$mypassword=$GLOBALS;
$mydbname=$GLOBALS;
$mytable=$GLOBALS;
$myorder=$GLOBALS;
$i = 0;
$db_con=mysql_connect($myhostname, $myusername, $mypassword) or die("Connetion to database failed!");
mysql_select_db($mydbname, $db_con);
if ($myorder == ""){
$query = "SELECT * FROM $mytable";
}
else {
$query = "SELECT * FROM $mytable ORDER BY $myorder";
}
$myresult = mysql_query($query, $db_con);
/* make sure data was retrieved */
if(!$myresult) die("Data Query Failed.");
if(!$myresult) die("Get_Data Function Failed.");
return $myresult;
}
function display_SQL_data() {
$i=0;
$myresult=$GLOBALS;
$mysort_col=$GLOBALS;
$file_db=$GLOBALS;
if(!$myresult) die("No Data to display.");
/* Number of columns in SQL*/
while ($i < mysql_num_fields($myresult)) {
$meta = mysql_fetch_field($myresult);
$columns = $meta->name;
$i++;
}
/*Creat the table and display the data */
/*Table Header */
echo "<table cellspacing=\"0\" cellpadding=\"4\" border=\"1\" width=\"90%\">\n";
echo "<tr><td colspan=\"" . (sizeof($columns)+2) . "\">\n";
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\" width=\"100%\">\n";
echo "<tr><td class=\"big\" bgcolor=\"#000000\" align=\"center\" valign=\"middle\">\n";
/* Normal Records Header*/
if ($mysort_col == ""){
echo "<font color=\"#ffffff\">Records Table</td></tr></table></td></tr><tr>\n";
}
/* Sorted Records Header*/
else {
echo "<font color=\"#ffffff\">Sorted Records Table</td></tr></table></td></tr><tr>\n";
}
/* Display Column Titles*/
/* Display Column Titles for SQL. */
for($i=0;$i<sizeof($columns);$i++) {
echo "<td align='center' valign='middle'>\n";
echo "<table cellspacing='0' cellpadding='0' border='1' width='100%'>\n";
echo "<td class='small' bgcolor='#000000' align='center' valign='middle'>\n";
echo "<a href='index.php?sort_col=".$i."'><center><b>".$columns."</td>\n";
echo "</td></table></td>\n";
}
echo "<td class='small' bgcolor='#000000' colspan='2' align='center' valign='middle'><center>";
echo "<a href=\"printer_friendly_all.php\">Print All</a>";
echo "</tr>";
while($row=mysql_fetch_array($myresult)) {
echo "<tr>";
for($i=0;$i<sizeof($columns);$i++) {
echo "<td class='small'><center>".$row[$columns]."</td>";
}
$j=$row[$columns];
echo "<td class='small' bgcolor='#000000' align='center' valign='middle'><center>";
if($file_db != 1) {
echo "<a href='delete_rec.php?id=".$j."'>delete</a></td>";
} else {
echo "<a href='delete_file_rec.php?id=".$j."'>delete</a></td>";
}
echo "<td class='small' bgcolor='#000000' align='center' valign='middle'><center>";
echo "<a href=\"printer_friendly.php?id=".$j."\">Print</a></td>";
}
echo "<tr><td class='small' bgcolor='#000000' colspan=\"".(sizeof($columns)+2)."\" align='center' valign='middle'>";
echo "<center><a href=\"printer_friendly_all.php\">Print All</a>";
echo "</tr></table>";
}
?>
<br /><br />
</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR /></TD></TR>
<TR>
<TD class=small align=right>opensource design © 2001</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<a href="http://sourceforge.net">
<img src="http://sourceforge.net/sflogo.php?group_id=45605&type=5" width="210" height="62" border="0" alt="SourceForge Logo"></a>
</center></form>
</body></html>