Php Update

Currently we need part of our existing website updated so it pulls info such as categories out of the database rather than it being hard coded. Half the website updates categories and locations from the database whilst other parts do not. For example this is the hard coded part we need changing:

function editDetails($ch1, $ch2, $ch3, $ch4, $ch5, $ch6, $ch7, $ch8, $ch9, $ch10, $ch11, $ch12, $ch13, $ch14, $ch15, $ch16, $ch17, $ch18, $ch19, $ch20, $ch21, $ch22, $ch23, $ch24, $ch25, $ch26, $ch27, $ch28) {
global $database, $form;
isset($ch1) ? $database->updateDetailsField($this->username, “job_category1”, “1”) : $database->updateDetailsField($this->username, “job_category1”, “0”);
isset($ch2) ? $database->updateDetailsField($this->username, “job_category2”, “1”) : $database->updateDetailsField($this->username, “job_category2”, “0”);
isset($ch3) ? $database->updateDetailsField($this->username, “job_category3”, “1”) : $database->updateDetailsField($this->username, “job_category3”, “0”);
isset($ch4) ? $database->updateDetailsField($this->username, “job_category4”, “1”) : $database->updateDetailsField($this->username, “job_category4”, “0”);
isset($ch5) ? $database->updateDetailsField($this->username, “job_category5”, “1”) : $database->updateDetailsField($this->username, “job_category5”, “0”);
isset($ch6) ? $database->updateDetailsField($this->username, “job_category6”, “1”) : $database->updateDetailsField($this->username, “job_category6”, “0”);
isset($ch7) ? $database->updateDetailsField($this->username, “job_category7”, “1”) : $database->updateDetailsField($this->username, “job_category7”, “0”);
isset($ch8) ? $database->updateDetailsField($this->username, “job_category8”, “1”) : $database->updateDetailsField($this->username, “job_category8”, “0”);
isset($ch9) ? $database->updateDetailsField($this->username, “job_category9”, “1”) : $database->updateDetailsField($this->username, “job_category9”, “0”);
isset($ch10) ? $database->updateDetailsField($this->username, “job_category10”, “1”) : $database->updateDetailsField($this->username, “job_category10”, “0”);
isset($ch11) ? $database->updateDetailsField($this->username, “job_sector1”, “1”) : $database->updateDetailsField($this->username, “job_sector1”, “0”);
isset($ch12) ? $database->updateDetailsField($this->username, “job_sector2”, “1”) : $database->updateDetailsField($this->username, “job_sector2”, “0”);
isset($ch13) ? $database->updateDetailsField($this->username, “job_sector3”, “1”) : $database->updateDetailsField($this->username, “job_sector3”, “0”);
isset($ch14) ? $database->updateDetailsField($this->username, “job_sector4”, “1”) : $database->updateDetailsField($this->username, “job_sector4”, “0”);
isset($ch15) ? $database->updateDetailsField($this->username, “job_sector5”, “1”) : $database->updateDetailsField($this->username, “job_sector5”, “0”);
isset($ch16) ? $database->updateDetailsField($this->username, “job_sector6”, “1”) : $database->updateDetailsField($this->username, “job_sector6”, “0”);
isset($ch17) ? $database->updateDetailsField($this->username, “job_sector7”, “1”) : $database->updateDetailsField($this->username, “job_sector7”, “0”);
isset($ch18) ? $database->updateDetailsField($this->username, “job_sector8”, “1”) : $database->updateDetailsField($this->username, “job_sector8”, “0”);
isset($ch19) ? $database->updateDetailsField($this->username, “job_location1”, “1”) : $database->updateDetailsField($this->username, “job_location1”, “0”);
isset($ch20) ? $database->updateDetailsField($this->username, “job_location2”, “1”) : $database->updateDetailsField($this->username, “job_location2”, “0”);
isset($ch21) ? $database->updateDetailsField($this->username, “job_location3”, “1”) : $database->updateDetailsField($this->username, “job_location3”, “0”);
isset($ch22) ? $database->updateDetailsField($this->username, “job_location4”, “1”) : $database->updateDetailsField($this->username, “job_location4”, “0”);
isset($ch23) ? $database->updateDetailsField($this->username, “job_location5”, “1”) : $database->updateDetailsField($this->username, “job_location5”, “0”);
isset($ch24) ? $database->updateDetailsField($this->username, “job_location6”, “1”) : $database->updateDetailsField($this->username, “job_location6”, “0”);
isset($ch25) ? $database->updateDetailsField($this->username, “job_type1”, “1”) : $database->updateDetailsField($this->username, “job_type1”, “0”);
isset($ch26) ? $database->updateDetailsField($this->username, “job_type2”, “1”) : $database->updateDetailsField($this->username, “job_type2”, “0”);
isset($ch27) ? $database->updateDetailsField($this->username, “job_type3”, “1”) : $database->updateDetailsField($this->username, “job_type3”, “0”);
isset($ch28) ? $database->updateDetailsField($this->username, “job_type4”, “1”) : $database->updateDetailsField($this->username, “job_type4”, “0”);
isset($ch25) ? $database->updateDetailsField($this->username, “job_type1”, “1”) : $database->updateDetailsField($this->username, “job_type1”, “0”);

$q2 = “INSERT INTO user_details(`username`, `job_category1`, `job_category2`, `job_category3`, `job_category4`, `job_category5`, `job_category6`, `job_category7`, `job_category8`, `job_category9`, `job_category10`, `job_sector1`, `job_sector2`, `job_sector3`, `job_sector4`, `job_sector5`, `job_sector6`, `job_sector7`, `job_sector8`, `job_location1`, `job_location2`, `job_location3`, `job_location4`, `job_location5`, `job_location6`, `job_type1`, `job_type2`, `job_type3`, `salary_from`, `salary_to`, `cv_path`, `cover_letter`) VALUES(‘$username’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’, ‘0’)”;

<input name=”ch1″ type=”checkbox” value=”Residential” <?php if($database->getDetailsField($session->username, “job_category1”) == “1”) { echo “checked=\”checked\””; }?> />
<input name=”ch2″ type=”checkbox” value=”Commercial” <?php if($database->getDetailsField($session->username, “job_category2”) == “1”) { echo “checked=\”checked\””; }?> />

Here is an example of how we pull categories out of the database on other parts of the website:

<?php
$query = “SELECT name, id FROM category”;
$res = mysql_query($query) or die(mysql_error());
while($a = mysql_fetch_array($res)) {
echo “<option value=”.””.$a[1].””.””.((isset ($_GET[‘categories’])

Leave a Reply

Your email address will not be published. Required fields are marked *