}
?>
#--------------------------------------------------
# filename - mysqlifunction.php
# Date - 14/12/2007
# Purpose - sql functions here
#--------------------------------------------------
CLASS SQL_FUNC_TION
{
#this function is used to connect server and database
function connect_db($dbname,$username,$pass,$server)
{
//echo $server."
";
//echo $username."
";
//echo $pass."
";
$connect_return = mysqli_connect("$server","$username","$pass");
if( $connect_return ){
mysqli_select_db($connect_return,$dbname);
}
else{
die("Could not connect: " . mysqli_error());
}
return $connect_return;
//echo "Connect Return"." "."$connect_return"."
";
}#end function connect_db
function connect_to_db()
{
//$this->connect_db(DBNAME,USERNAME,PASSWORD,HOSTNAME);
}#end function connect_to_db
#this function is used to execute sql query
function query_db($conn,$qstring)
{
//$this->connect_db(DBNAME,USERNAME,PASSWORD,HOSTNAME);
Global $ms_error;
$res = mysqli_query($conn,$qstring) or die(mysqli_error()."error111");
//echo "RES".$res;
return $res;
}#end function query_db
function result_db1($re,$row,$field)
{
$row1 = count($field);
for($i=0;$i<$row;$i++)
{
for($j=0;$j<$row1;$j++)
{
$result[] = mysqli_result($re,"$i","$field[$j]");
}
}
return $result;
}
#this function is used to get number of rows from the result set
function row_db($rvalue)
{
if($rvalue != "")
{
//echo "$rvalue"."
";
$row = mysqli_num_rows($rvalue);
return $row;
}
else
{
return 0;
}
}#end function row_db
#this function is used to insert record in db
function insertid_db()
{
//$this->connect_db(DBNAME,USERNAME,PASSWORD,HOSTNAME);
$id = mysqli_insert_id();
//echo "
".$id."
";
//$this->close_db();
return $id;
}# end function insertid_db
#this function is used to get error number
function errno_db()
{
$errno = mysqli_errno();
return $errno;
}#end function errno_db
#this function is used to return sql errors
function err_db()
{
//echo mysqli_error();
return mysqli_error();
}#end function err_db
#this function is used to get affected rows
function aff_row()
{
$affrow = mysqli_affected_rows();
return $affrow;
}#end function aff_row
#this function is used to get the result in array
function result_db($re)
{
$Number_Of_Rows = $this->return_Number_Of_Rows($re);
$count=0;
# To populate the first row as array of Names of the fields in table
$rows_as_array[$count] = $this->return_Names_Of_Fields_As_Array($re);
# Start from populating the array with array from the 2nd row.
for ($count = 1; $count < $Number_Of_Rows+1; $count++)
{
$rows_as_array[$count]= mysqli_fetch_object ($re);
}
return $rows_as_array;
}#end function result_db
#this function is used to disconnect database
function close_db()
{
//mysqli_close();
}#end function close_db
#this function is used to get number of fields retrieved in result set
function return_Number_Of_Fields($result_identifier)
{
$Number_Of_Fields = @mysqli_num_fields($result_identifier);
return $Number_Of_Fields;
}# end function return_Number_Of_Fields
#this function is used to get number of rows from result set
function return_Number_Of_Rows($result_identifier)
{
$Number_Of_Rows = @mysqli_num_rows($result_identifier);
return $Number_Of_Rows;
}# end function return_Number_Of_Rows
#this function is used to get field name in array
function return_Names_Of_Fields_As_Array($result_identifier)
{
$no = $this->return_Number_Of_Fields($result_identifier);
for ($count = 0; $count < $no; $count++)
{
$field_name=mysqli_field_name($result_identifier,$count);
$test=$Names_Of_Fields[$field_name] =$field_name;
}
$no = $this->return_Number_Of_Rows($result_identifier);
return $Names_Of_Fields;
}# end of return_Name_Of_Fields_As_Array
#this function is used to call function to get result
function get_result($sql_query)
{
//$this->connect_db(DBNAME,USERNAME,PASSWORD,HOSTNAME);
$sql_result=$this->query_db($sql_query);
$sql_resultarray=$this->result_db($sql_result);
return $sql_resultarray;
//$this->close_db();
}# end of get_result
#this function is used to call function to delete record
function del_record($conn,$tablename,$id_name,$id)
{
//$this->connect_db(DBNAME,USERNAME,PASSWORD,HOSTNAME);
$sql_query="DELETE FROM ".$tablename." WHERE ".$id_name." =".$id." LIMIT 1";
$sql_result=$this->query_db($conn,$sql_query);
//$this->close_db();
return $sql_result;
}# end of get_result
# function to insert record
function insertrecord($conn,$tablename,$array)
{
//$this->connect_db(DBNAME,USERNAME,PASSWORD,HOSTNAME);
$counttimer=1;
$tablefields="";
$formfield="";
foreach ($array as $key => $val)
{
$tablefields .= $key;
$formfield .= "\"".addslashes($val)."\"";
if(count($array)!=$counttimer)
{
$tablefields .=",";
$formfield .= ",";
}
$counttimer=$counttimer+1;
}
$sql = "insert into ".$tablename."(".$tablefields.") values (".$formfield.")";
$res=$this->query_db($conn,$sql);
$this->close_db();
return $res;
}
# function to update record
function updaterecord($conn,$tablename,$array,$where)
{
$update_fields="";
$counttimer=1;
foreach ($array as $key => $val)
{
$update_fields .=$key ."= \"" . addslashes($val)."\"";
if(count($array)!=$counttimer)
{
$update_fields .=",";
}
$counttimer=$counttimer+1;
}
$counttimer=1;
if($where!="")
{
$where_string ="";
foreach ($where as $key => $val)
{
$where_string .=$key ."= '" . $val."'";
if(count($where)!=$counttimer)
{
$where_string .=" and ";
}
$counttimer=$counttimer+1;
}
}
$sql = "update ".$tablename." set ".$update_fields;
if($where!="")
{
$sql.=" where ".$where_string;
}
$res=$this->query_db($conn,$sql);
//echo "
".$sql."
";
return $res;
}
#end of updaterecord function
}#end of class SQL_FUNCTION
?>
Click on each county to view hunting properties
|
//echo "hostname=".$hostname." username =".$username." pass=".$pass."dbname=".$dbname;
include("index1.php");
if(isset($_GET['id']))
{
?>
$conn =mysqli_connect($hostname, $username, $pass);
mysqli_select_db($conn,$dbname);
$property_sql = 'select * from property where property_county='.$_GET['id'];
$property_rs = mysqli_query($conn,$property_sql) or die(mysqli_error()."error111");
while($property_row = mysqli_fetch_assoc($property_rs)){
$photo_sql = 'select * from photo where property_id='.$property_row['property_id']. " LIMIT 1";
$photo_rs = mysqli_query($conn,$photo_sql) or die(mysqli_error()."**error111");
$photo_row = mysqli_fetch_array($photo_rs);
$photo1="photo/thumbnail/".$photo_row['photo_thumbnail'];
$photo2="photo/midimg/".$photo_row['photo_mid_image'];
if($property_row['property_status']==1)
{
$status="AVAILABLE";
$buttoncolor="green";
}
else
{
$status="LEASED";
$buttoncolor="brown";
}
$county_sql = 'select * from county where county_id='.$property_row['property_county'];
$county_rs = mysqli_query($conn,$county_sql) or die(mysqli_error()."error111");
$county = mysqli_fetch_array($county_rs);
?>
|
}
?>
}
?>
include("testimonial.php"); ?>
include("footer.php");
?>