PHP Class Utility"; echo ""; $who = "race"; $good_user = @mysql_connect( "samba2.ipm.virginia.edu", "selectuser", ""); mysql_select_db( "test"); $selectstring = " show columns from race"; $query_handle = mysql_query( $selectstring); $num_rows = mysql_num_rows ($query_handle); echo "Automatically create class info for the race table


"; // the next loop creates the constructor echo "class $who
{
"; mysql_data_seek($query_handle, 0); for( $i = 0; $i < -1; $i++) { echo ""; $row = mysql_fetch_array ($query_handle); $sizerow = sizeof( $row) / 2; $k = $i + 1; $j = 0; echo "var \$$row[$j];
\n"; } echo "
"; echo "// *******************************************
"; echo "// ********** constructor ********************
"; echo "// *******************************************
"; echo "

function " . $who . "()
"; echo "{
"; mysql_data_seek($query_handle, 0); for( $i = 0; $i < $num_rows; $i++) { $row = mysql_fetch_array ($query_handle); $sizerow = sizeof( $row) / 2; $k = $i + 1; $j = 0; echo " \$this->" . $row[$j] . ' = " ";
' . "\n" ; } echo "} // end constructor

"; // this loop creates the program to load the class from the database echo "

function init_" . $who . "( \$row)
"; echo "{

\n"; mysql_data_seek($query_handle, 0); for( $i = 0; $i < $num_rows; $i++) { echo ""; $row = mysql_fetch_array ($query_handle); $j = 0; echo " \$this->" . $row[$j] . ' = $row["' . $row[$j] . '"];' . "
\n"; } echo "} // init race

} // class"; // this loop writes all the code for a generic data entry form echo "


Text for Data Entry Form:

\n"; echo ""; ?>