Site Cloner PHP Script
Bargain Hunter PHP Script
Job Hunter PHP Script
Site Login and Access Control PHP Script

MYSQL FETCH ARRAY

$host = “localhost”;
$user = “root”;
$pw = “”;
$database = “test”;
$db = mysqli_connect($host, $user, $pw, $database) or die(“Cannot connect to mySQL.”);

//$sql = “SELECT * FROM table1”;
//$result = mysqli_query($db, $sql);
$command = “SELECT * FROM table1”;
$result = mysqli_query($db, $command);
//see the array of what is there
//print_r(mysqli_fetch_assoc($result));
if($row = mysqli_fetch_array($result)/*mysqli_fetch_assoc($result)*/) {
//SET UP VARIABLES
$id = $row[‘id’];
$column2 = $row[‘column2’];
$column3 = $row[‘column3’];
$column4 = $row[‘column4’];
$column5 = $row[‘column5’];
$column6 = $row[‘column6′];
echo “Column 2 is: “.$column2;
#check to see if entered
if($column6 == “”){
//column titles
if($column4 == “This Text”){
$column6 = “New Text”;
}
if($column4 == “This Different Text”){
$column6 = “Different New Text”;
}
//update table
$sql = “UPDATE table SET column6=’$column6’ WHERE id=’$id'”;
$result = mysqli_query($db, $sql) or die(mysqli_error($db));
}
}