[eluser]_Moat_[/eluser]
i'll try my best to include what ever piece of code required.
controller:
Code:
public function Index()
{
$query = array();
$data['frm1_ctg'] = $this->edit_page_db->getPageInfo("4");
if ($this->input->post('form1'))
{
$business = $this->input->post('business_f1');
$street = $this->input->post('street');
$city = $this->input->post('city');
$postal = $this->input->post('postal');
$phone = $this->input->post('phone');
$category = $this->input->post('ID');
$query = array('PAGE_NAME'=> $business, 'PAGE_CATEGORY_ID'=> null,'OFFICIAL_PAGE'=> null,'START_DATE'=>null,'STREET_ADDRESS'=>$street,'CITY_TOWN_NAME'=>$city,'CITY_TOWN_ID'=>null, 'POSTCODE'=>$postal, 'ABOUT' => null, 'COMPANY_OVERVIEW' => null, 'DESCRIPTION' => null, 'MISSION' => null, 'AWARDS'=>null, 'PRODUCTS'=>null, 'PHONE' => $phone, 'EMAIL'=>null, 'WEBSITE' => null);
echo "$business . $street . $city . $postal . $phone . $category ";
// Businnes Or Place Street Adress City/Country Postal Code Phone 0 "HERE"
if ($business != "Business or Places" && $street != "Street Adress" && $city != "City/Country" && $postal != "Postal Code" && $phone != "Phone" )
{
$this->form_validation->set_rules('ID','Category','required');
$this->form_validation->set_rules('business_f1','Business or Places','required');
$this->form_validation->set_rules('street','Street Adress','required');
$this->form_validation->set_rules('city','City or Country','required');
$this->form_validation->set_rules('postal','Postal Code','required');
$this->form_validation->set_rules('phone','Phone','required');
}
} // end of if ($this->input->post('form1'))
if (!$this->form_validation->run())
{
$data['message_error'] = validation_errors();
$this->load->view('create_page',$data);
}
else
{
$this->edit_page_db->saveInfo($query);
$this->load->view('edit_page_info',$data);
}
} //end of index
view:
Code:
<select name="ID">
<option>Chose a Category</option>
<?php $i = 0; foreach ($frm1_ctg as $key) { ?>
<option value="<?php echo set_value() == "" ? ($frm1_ctg[$i]['ID']) : set_value("ID") ?>"><?php echo $frm1_ctg[$i]['CATEGORY_NAME'];?>
</option>
<?php $i++;} ?>
</select>
<input id="business_f1" name ='business_f1' value="<?php echo set_value() == "" ? "Businnes Or Place" : set_value("business"); ?>" type="text" class="stretch">
</input>
<input id="street" name ='street' value="<?php echo set_value() == "" ? "Street Address" : set_value("street"); ?>" type="text" class="stretch">
</input>
<input id="city" name = 'city' value ="<?php echo set_value() == "" ? "City/Country" : set_value('city'); ?>" type="text" class="stretch">
</input>
<input id="postal" name = "postal" value="<?php echo set_value() == "" ? "Postal Code" : set_value('postal'); ?>" type="text" class="stretch">
</input>
<input id="phone" name = "phone" value="<?php echo set_value() == "" ? "Phone" : set_value('phone'); ?>" type="text" class="stretch">
</input>
<input value="true" type="checkbox" id="checkbox_text_f1">
<div id="checkbox_text">I agree to</div>
<a href="/" class="igotshare_terms">IGotShare Pages Terms</a>
</input>
<input type="submit" class="submit_btn" value="Get Started" name="form1">
model:
Code:
class edit_page_db extends CI_Model
{
function __construct()
{
$this -> load -> database();
}
public function saveInfo($query)
{
$this -> db -> insert('igs_page', $query);
}
public function getPageInfo($parentID)
{
$sql = "select ID, CATEGORY_NAME from igs_page_category where CATEGORY_PARENT_ID in ($parentID)";
$query = $this -> db -> query($sql,$parentID);
if ($query -> num_rows() > 0)
{
foreach ($query->result_array() as $row)
{
$ctg_ids[] = $row;
}
return $ctg_ids;
}
}
this is all my old code nothing changed