Hi
I am struggling with a need for my variable $id to be available throughout my index.php file so that i can identify with record i am going to alter within my database.
HTML Code:
if (isset ($_POST['action']) and $_POST['action'] == 'Search')
{
$id = mysqli_real_escape_string ($link, $_POST['propid_text']); //Get id input
if ($id <> '') //if ID not blank
{
$sql = 'SELECT id,jobref,House_name, house_number, addline1, addline2, town, County, postcode, fee, job, surveyor, client from property where id = '.$id.'';
$result = mysqli_query ($link, $sql);
if (!$result)
{
$error = 'Error - Please enter a valid ID. ' . mysqli_error($link);
include 'error.html.php';
exit();
}
if ($result<>'')
{
while ($row = mysqli_fetch_array ($result))
{
$invoices[] = array (
'id' => $row['id'],
'House_name' => $row['House_name'],
'house_number' => $row['house_number'],
'addline1' => $row['addline1'],
'addline2' => $row['addline2'],
'town' => $row['town'],
'county' => $row['county'],
'postcode' => $row['postcode'],
'fee' => $row['fee'],
'job' => $row['job'],
'surveyor' => $row['surveyor'],
'client' => $row['client']);
}
include 'list.html.php';
exit();
/*echo '<pre>';
print_r($invoices);
echo '</pre>'; */
}
}
else
{
echo 'Enter an ID';
}
}
// Confirm correct record to invoice
if (isset ($_POST['action']) and $_POST['action']=='Invoice')
{
include 'confirm.html.php';
exit();
}
if (isset ($_POST['action']) and $_POST['action'] = 'Yes')
{
$id;
echo 'yes was pressed';
echo $id. ' id still here';
$test = 1;
}
else if (isset ($_POST['action']) and $_POST['action'] = 'No')
{
include 'searchform.html.php';
exit();
}
$id is set early in the first if statement, However it is not available in the if statsments towards the rear. I am thinking this is likely due to the variables ‘scope’ but I am a newb and at a loss as to how to go about making sure it is available throughout.
Any comments regarding this greatly excepted.
Many thanks