Market Analysis
$conn = mysqli_connect(‘10.169.0.19’, ‘yourbuy2_admin’, ‘test123′,’yourbuy2_data’);
// Check connection
if (!$conn) {
die(“Connection failed: ” . mysqli_connect_error());
}
if (isset($_POST[“Update”])) {
$id = $_POST[‘MarketAnalysisID’];
$MATown = $_POST[‘Town’];
$MAPostcode = $_POST[‘Postcode’];
$MAYield = $_POST[‘Yield’];
$sqlupdate = “UPDATE `wp_pp_marketanalysis` SET `MarketAnalysisID`=’$id’,`Town`=’$MATown’,`Postcode`=’$MAPostcode’,`Yield`=’$MAYield’ WHERE `MarketAnalysisID`=$id and `MyUserID`=$UserID”;
$retvalue=mysqli_query($conn,$sqlupdate);
if(! $retvalue)
{
die(‘could not update data’.mysql_error());
}
}
if (isset($_POST[“Delete”])) {
$id = $_POST[‘PropertyValueID’];
$sqldelete = “Delete From `wp_pp_marketanalysis` WHERE `MarketAnalysisID`=$id”;
$retvalue=mysqli_query($conn,$sqldelete);
if(! $retvalue)
{
die(‘could not update data’.mysql_error());
}
}
if (! $PASortBy)
{
$sql = “SELECT * FROM `wp_pp_marketanalysis` where `MyUserID`=$UserID ORDER BY `Yield` DESC”;
} else {
$sql = “SELECT * FROM `wp_pp_marketanalysis` where `MyUserID`=$UserID ORDER BY `$PASortBy` $PAAscDesc”;
}
$result=$conn->query($sql);
echo ‘
echo ‘
‘;
echo ‘
‘;
// mysqli_close($conn);
[/insert_php]