It shows me this error: Column 'zeme_idZeme' cannot be null
I thought <select name="zeme_IdZeme"> this would be sufficient, but I was wrong about it.
View:
<body>
<div class="main-block">
<h1>Film</h1>
<form method="post" action="<?php echo base_url('/form') ?>">
<div class="info">
<input type="text" name="cesky_nazev" required="vyžadováno" placeholder="Český název filmu">
<input type="text" name="originalni_nazev" required="vyžadováno" placeholder="Původní název filmu">
<input type="number" name="delka_filmu" required="vyžadováno" placeholder="Délka filmu">
<input type="text" name="typ_filmu" required="vyžadováno" placeholder="Typ filmu">
<select name="zeme_IdZeme">
<option disabled selected>Země</option>
<?php
$query = $db->query("SELECT * FROM zeme");
foreach ($query->getResult() as $row)
{ ?>
<option value="5"> <?php echo $row->nazev;}?></option>
</select>
</div>
<button type="submit" class="button">Odeslat</button>
</form>
</div>
</body>
Controller:
public function form() {
$data = [ 'cesky_nazev' =>$this->request->getVar('cesky_nazev'),
'originalni_nazev' =>$this->request->getVar('originalni_nazev'),
'delka_filmu' =>$this->request->getVar('delka_filmu'),
'typ_filmu' =>$this->request->getVar('typ_filmu'),
'zeme_idZeme' =>$this->request->getVar('zeme_idZeme'),
'zanrFilmu_idZanrFilmu' =>$this->request->getVar('zanrFilmu_idZanrFilmu'),
'promitani_idPromitani' =>$this->request->getVar('promitani_idPromitani'),
'jazyky_idJazyky' =>$this->request->getVar('jazyky_idJazyky') ];
/*
$db = \Config \Database::connect();
$builder = $db->table('film');
$builder->insert($data); */
$model = new Film_formular();
if ($model->insert($data))
{
echo view('templates/header');
?><style>.center {text-align: center;color: red;}</style><?php
echo "<h3 class='center'>Úspěšně přidáno</h3>";
echo view('film_formular');
echo view('templates/footer');
}
else
{
echo "nepřidáno";
}
}
model:
<?php namespace App\Models;
use CodeIgniter\Model;
class Film_formular extends Model
{
protected $table = 'film';
protected $allowedFields = ['cesky_nazev', 'originalni_nazev', 'delka_filmu', 'typ_filmu', 'zeme_idZeme', 'zanrFilmu_idZanrFilmu','promitani_idPromitani','jazyky_idJazyky'];
}
The option close tag aren't inside foreach. Move the bracket after option close tag
<select name="zeme_IdZeme">
<option disabled selected>Země</option>
<?php
$query = $db->query("SELECT * FROM zeme");
foreach ($query->getResult() as $row)
{
?>
<option value="5"> <?php echo $row->nazev;?></option>
<?php
}
?> </select>
Related
I can't get my form_update_manga.php page to receive the values from the records that the form_read_manga.php page sends.
None of the fields return any value from the record, making it impossible to update the form. By the way, there is no way to do anything in this form. I can't find a logical solution.
The error that occurs in the form_update_manga.php page is shown in the figure below:
Image here
Error in most form fields: Trying to access array offset on value of type bool
Manga.php
<?php
require_once '../model/BD.php';
class Manga extends BD {
private $id_manga, $title, $publisher, $volumes, $discount, $value;
public function getId() { return $this->id_manga; }
public function getTitle() { return $this->title; }
public function getPublisher() { return $this->publisher; }
public function getVolumes() { return $this->volumes; }
public function getDiscount() { return $this->discount; }
public function getValue() { return $this->value; }
public function setId($id_manga) { $this->id_manga = $id_manga; }
public function setTitle($title) { $this->title = $title; }
public function setPublisher($publisher) { $this->publisher = $publisher; }
public function setVolumes($volumes) { $this->volumes = $volumes; }
public function setDiscount($discount) { $this->discount = $discount; }
public function setValue($value) { $this->value = $value; }
}
?>
MangaDAO.php
protected $table = 'manga';
public function readManga() {
try {
$sql = "SELECT * FROM $this->table WHERE id_manga = :id_manga";
$stm = BD::getInstance()->prepare($sql);
$stm->bindValue(':id_manga', $this->getId());
$stm->execute();
return $stm->fetch(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
echo "Error PDO" . $e->getMessage();
die();
} catch (Exception $e) {
echo "Error" . $e->getMessage();
die();
}
}
public function updateManga() {
try {
$sql = "UPDATE $this->table SET title = :title, publisher = :publisher,
volumes = :volumes, discount = :discount, value = :value WHERE id_manga = :id_manga";
$stm = BD::getInstance()->prepare($sql);
$stm->bindValue(':id_manga', $this->getId());
$stm->bindValue(':title', $this->getTitle());
$stm->bindValue(':publisher', $this->getPublisher());
$stm->bindValue(':volumes', $this->getVolumes());
$stm->bindValue(':discount', $this->getDiscount());
$stm->bindValue(':value', $this->getValue());
return $stm->execute();
} catch (PDOException $e) {
echo "Error PDO" . $e->getMessage();
die();
} catch (Exception $e) {
echo "Error ". $e->getMessage();
die();
}
}
form_read_manga.php
<div class="container" style="margin-top: 40px;">
<h4 class="text-center">Manga list</h4>
<br>
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Publisher</th>
<th>Volumes</th>
<th>Discount</th>
<th>Value collection</th>
<th>Register date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
require_once "../model/MangaDAO.php";
$manga = new MangaDAO();
foreach ($manga->readAllMangas() as $value){
echo '<tr>';
echo '<td>'.$value['id_manga'].'</td>';
echo '<td>'.$value['title'].'</td>';
echo '<td>'.$value['publisher'].'</td>';
echo '<td>'.$value['volumes'].'</td>';
echo '<td>'.$value['discount'].'</td>';
echo '<td>R$'.$value['value'].'</td>';
echo '<td>'.date('d/m/Y H:i:s', strtotime($value['register_date'])).'</td>';
echo '<td>';
echo '<a class="btn btn-info" href="/mangas/view/form_update_manga.php?id_manga='.$value['id_manga'].'"role="button" ><i class="fa fa-edit"></i> Update</a>';
echo " ";
echo '<a class="btn btn-danger" href="/mangas/controller/delete_manga.php?id_manga='.$value['id_manga'].'"role="button"><i class="fa fa-trash"></i> Delete</a>';
echo '</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
form_update_manga.php
<?php
require_once "../model/MangaDAO.php";
$mangaDAO = new MangaDAO();
if (!isset($_GET['id_manga'])) {
echo '<p><button>Redo operation</button></p>';
die();
} else {
$data = $mangaDAO->readManga($_GET['id_manga']);
}
?>
<div class="container" id="t_container" style="margin-top: 20px;">
<h4 class="text-center">Update collection</h4>
<small class="form-text text-muted text-center">All fields are mandatory</small>
<br>
<form method="POST" action="/mangas/controller/update_manga.php">
<div class="form-group">
<label>ID:</label>
<input type="number" class="form-control" name="id_manga" required value="<?php echo $data['id_manga'] ?>" disabled>
</div>
<div class="form-group">
<label>Title:</label>
<input type="text" class="form-control" name="title" required maxlength="50" value="<?php echo $data['title'] ?>">
</div>
<div class="form-group">
<label>Publisher:</label>
<select class="custom-select" name="publisher" required value="<?php echo $data['publisher'] ?>">
<option selected value="">Choose the publisher</option>
<option value="Astral Comics" title="Astral Comics">Astral Comics</option>
<option value="Clamp" title="Clamp">Clamp</option>
<option value="Conrad" title="Conrad">Conrad</option>
<option value="Darkside Books" title="Darkside Books">Darkside Books</option>
<option value="Devir" title="Devir">Devir</option>
<option value="JBC" title="JBC">JBC</option>
<option value="NewPop" title="NewPop">NewPop</option>
<option value="Nova Sampa" title="Nova Sampa">Nova Sampa</option>
<option value="Panini" title="Panini">Panini</option>
<option value="Pipoca & Nanquim" title="Pipoca & Nanquim">Pipoca & Nanquim</option>
<option value="Veneta" title="Veneta">Veneta</option>
<option value="Other" title="Other">Other</option>
</select>
</div>
<div class="form-group">
<label>Volumes amount:</label>
<input type="text" class="form-control" name="volumes" required onkeypress="$(this).mask('000', {reverse: true});" value="<?php echo $data['volumes'] ?>">
</div>
<div class="form-group">
<label>Discount:</label>
<input type="text" class="form-control" name="discount" required onkeypress="$(this).mask('000.00', {reverse: true});" value="<?php echo $data['discount'] ?>">
</div>
<div class="form-group">
<label>Value collection:</label>
<input type="text" class="form-control" name="value" required value="<?php echo $data['value'] ?>" onkeypress="$(this).mask('000.00', {reverse: true});">
</div>
<button type="submit" name="btn_update" class="btn btn-info btn-lg btn-block"><i class="fa fa-edit"></i> Update</button>
</form>
</div>
Replace your code with this in MangaDAO.php
protected $table = 'manga';
public function readManga($mangaId) {
try {
$sql = "SELECT * FROM $this->table WHERE id_manga = :id_manga";
$stm = BD::getInstance()->prepare($sql);
$stm->bindValue(':id_manga', $mangaId);
$stm->execute();
return $stm->fetch(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
echo "Error PDO" . $e->getMessage();
die();
} catch (Exception $e) {
echo "Error" . $e->getMessage();
die();
}
}
You have to put the selected attr to a specific value please refer to the below code.
<div class="form-group">
<label>Publisher:</label>
<select class="custom-select" name="publisher" required value="<?php echo $data['publisher'] ?>">
<option value="" <?php if($data['publisher']==''){echo 'selected';} ?>>Choose the publisher</option>
<option value="Astral Comics" title="Astral Comics" <?php if($data['publisher']=='Astral Comics'){echo 'selected';} ?>>Astral Comics</option>
<option value="Clamp" title="Clamp" <?php if($data['publisher']=='Clamp'){echo 'selected';} ?>>Clamp</option>
<option value="Conrad" title="Conrad" <?php if($data['publisher']=='Conrad'){echo 'selected';} ?>>Conrad</option>
<option value="Darkside Books" title="Darkside Books" <?php if($data['publisher']=='Darkside Books'){echo 'selected';} ?>>Darkside Books</option>
<option value="Devir" title="Devir" <?php if($data['publisher']=='Devir'){echo 'selected';} ?>>Devir</option>
<option value="JBC" title="JBC" <?php if($data['publisher']=='JBC'){echo 'selected';} ?>>JBC</option>
<option value="NewPop" title="NewPop" <?php if($data['publisher']=='NewPop'){echo 'selected';} ?>>NewPop</option>
<option value="Nova Sampa" title="Nova Sampa" <?php if($data['publisher']=='Nova Sampa'){echo 'selected';} ?>>Nova Sampa</option>
<option value="Panini" title="Panini" <?php if($data['publisher']=='Panini'){echo 'selected';} ?>>Panini</option>
<option value="Pipoca & Nanquim" title="Pipoca & Nanquim" <?php if($data['publisher']=='Pipoca & Nanquim'){echo 'selected';} ?>>Pipoca & Nanquim</option>
<option value="Veneta" title="Veneta" <?php if($data['publisher']=='Veneta'){echo 'selected';} ?>>Veneta</option>
<option value="Other" title="Other" <?php if($data['publisher']=='Other'){echo 'selected';} ?>>Other</option>
</select>
</div>
I have some problem with CodeIgniter, I can't update data in a record in CodeIgniter. 'id_user' is the primary key of my user table. I have tried to solve this problem but I couldn't. I hope someone can help with this problem. Thanks a lot :)
I have posted the code below :
HTML5 code :
<form action="<?php echo base_url(). 'crud/update'; ?>" method="post">
<input name="id_user" type="text" class="form-control" value="<?php echo $id_usernya ?>">
<div class="form-group">
<label>Alamat :</label>
<textarea name="alamat_user" class="form-control" rows="5" placeholder="Alamat" ><?php echo $usernya->alamat_user ?></textarea>
</div>
<div class="form-group">
<input name="kodepos_user" type="text" class="form-control" value="<?php echo $usernya->kodepos_user ?>">
</div>
<div class="form-group">
<input type="hidden" name="provinsi_user">
<select name="provinsi_id_user" class="form-control">
<option value="">Pilih Provinsi</option>
<option selected value="<?php echo $usernya->provinsi_user ?>"><?php echo $usernya->provinsi_user ?></option>
<?php echo $provinsi ?>
</select>
</div>
<div class="form-group">
<input type="hidden" name="kota_user">
<select name="kota_id_user" class="form-control">
<option value="">Pilih Kota</option>
<option selected value="<?php echo $usernya->kota_user ?>"><?php echo $usernya->kota_user ?></option>
</select>
</div>
<input type="submit" class="btn btn-primary" value="Simpan">
</form>
Controller :
class Crud extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->model('m_data');
$this->load->helper('url');
}
function edit($id_user){
$where = array('id_user' => $id_user);
$data['user'] = $this->m_data->edit_data($where,'user')->result();
$this->load->view('back/user/v_beranda',$data);
redirect('beranda/index');
}
function update(){
$id_user = $this->input->post('id_user');
$alamat_user = $this->input->post('alamat_user');
$kodepos_user = $this->input->post('kodepos_user');
$provinsi_id_user = $this->input->post('provinsi_id_user');
$kota_id_user = $this->input->post('kota_id_user');
$data = array(
'alamat_user' => $alamat_user,
'kodepos_user' => $kodepos_user,
'provinsi_id_user' => $provinsi_id_user,
'kota_id_user' => $kota_id_user
);
$where = array(
'id_user' => $id_user
);
$this->m_data->update_data($where,$data,'user');
redirect('beranda/index');
}
Model code :
<?php
class M_data extends CI_Model{
function edit_data($where,$table){
return $this->db->get_where($table,$where);
}
function update_data($where,$data,$table){
$this->db->where($where);
$this->db->update($table,$data);
}
}
Initialize your Model like what your have done on your Controller
class M_data extends CI_Model{
public function __construct() {
parent::__construct();
$this->load->database();
}
function edit_data($where,$table){
return $this->db->get_where($table,$where);
}
function update_data($where,$data,$table){
$this->db->where($where);
$this->db->update($table,$data);
}
}
try to print query to check what exact query getting executed
$this->db->last_query():
and which error its shows when you execute above query
I am doing some practicing with OOP in PHP, and am having issues with submitting form data involving subclasses.
What I am trying to do: submit form data based on the type of product it is (generic, tool, or electronic). My concern comes from not being able to submit a form that can differentiate between the different product types.
Here's the Product Class (the base class):
<?php
require_once('connectvars.php');
// Base class!!
class Product {
// Inheritable properties
protected $title;
protected $description;
protected $price;
// Getters
public function getTitle() {
return $this->title;
}
public function getDescription() {
return $this->description;
}
public function getPrice() {
return $this->price;
}
// Setters
public function setTitle($title) {
$this->title = $title;
}
public function setDescription($description) {
$this->description = $description;
}
public function setPrice($price) {
$this->price = $price;
}
public function insertProduct() {
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PW, DB_NAME);
$query = "INSERT INTO addedProducts VALUES (0,'$this->title', '$this->description', '$this->price', '', '', '')";
mysqli_query($dbc, $query)
or die("Error adding to database");
mysqli_close($dbc);
}
}
?>
Here's a subclass I made called Tools:
<?php
require_once('connectvars.php');
require_once('Product.php');
class Tools extends Product {
// Defined properties specific to Tools class
private $shipper;
private $weight;
// Getters
public function getShipper() {
return $this->shipper;
}
public function getWeight() {
return $this->weight;
}
// Setters
public function setShipper($shipper) {
$this->shipper = $shipper;
}
public function setWeight($weight) {
$this->weight = $weight;
}
public function insertTool() {
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PW, DB_NAME);
$query = "INSERT INTO addedProducts VALUES (0,'$this->title', '$this->description', '$this->price', '$this->shipper', '$this->weight', '')";
mysqli_query($dbc, $query)
or die("Error adding to database");
mysqli_close($dbc);
}
}
?>
This is where I am running into problems:
<!DOCTYPE html>
<html>
<head>
<title>Product Entry</title>
</head>
<body>
<select name="prodType" id="prodType">
<option value="" selected="selected">Select...</option>
<option value="general">General</option>
<option value="tools">Tools</option>
<option value="electronics">Electronics</option>
</select>
<br/><br/>
<?php
//require_once('connectvars.php');
require_once('Product.php');
require_once('Electronics.php');
require_once('Tools.php');
$product = new Product();
$tool = new Tools();
$electronic = new Electronics();
if (isset($_POST['submit']) && (isset($_POST['prodType']) == 'general')) {
$product_form = false;
$product->setTitle($_POST['title']);
$product->setDescription($_POST['description']);
$product->setPrice($_POST['price']);
$product->insertProduct();
/*$tool->setTitle($_POST['title']);
$tool->setDescription($_POST['description']);
$tool->setPrice($_POST['price']);
$tool->setShipper($_POST['shipper']);
$tool->setWeight($_POST['weight']);
if (!empty($tool->getTitle()) && !empty($tool->getDescription()) && is_numeric($tool->getPrice()) && !empty($tool->getShipper()) && !empty($tool- >getWeight())) {
echo 'Tool submitted <br/>';
//echo 'Go Back';
$tool->insertTool();
}
} else {
$product_form = true;
}
if ($product_form) {
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
<label for="title"><strong>Product Title</strong></label>
<br/>
<input type="text" id="title" name="title" value="<?php echo $product->getTitle();?>"/>
<br/><br/>
<label for="description"><strong>Description</strong></label>
<br/>
<input type="text" id="description" name="description" value="<?php echo $product->getDescription();?>"/>
<br/><br/>
<label for="price"><strong>Price</strong></label>
<br/>
<input type="text" id="price" name="price" value="<?php echo $product->getPrice();?>"/>
<br/><br/>
<!--For Tools -->
<label for="shipper"><strong>Shipper Info</strong></label>
<br/>
<select name="shipper" id="shipper">
<option value="none" selected="selected">--</option>
<option value="usps">USPS</option>
<option value="fedex">FedEx</option>
<option value="ups">UPS</option>
</select>
<br/><br/>
<label for="weight"><strong>Weight</strong></label>
<br/>
<input type="text" id="weight" name="weight" value="<?php echo $tool->getWeight();?>"/>
<br/><br/>
<!--For Electronics -->
<label for="recyclable"><strong>Recyclable?</strong></label>
<br/>
<select name="recyclable" id="recyclable">
<option value="none" selected="selected">--</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<br/><br/>
<input type="submit" id="submit" name="submit" value="Submit Product"/>
</form>
<?php
}
?>
</body>
</html>
I'm sure there's a fairly straightforward solution, but I'm no longer thinking about this correctly anymore -_-. Any suggestions?
I would do the following:
Move all of your calculations to the top of the file.
Move your prodType into the form.
I am displaying the form always. In 1 instance it is to edit, in another it is to create. But you will want to add a hidden input for the "product_id"
Like this:
<?php
require_once('Product.php');
require_once('Electronics.php');
require_once('Tools.php');
$product = new Product();
$tool = new Tools();
$electronic = new Electronics();
if (isset($_POST['submit'])){
$prodType = $_POST['prodType'];
if($prodType == 'general') {
$product_form = false;
$product->setTitle($_POST['title']);
$product->setDescription($_POST['description']);
$product->setPrice($_POST['price']);
$product->insertProduct();
} else if($prodType == 'tools') {
} else if ($prodType == 'elecronics') {
} else {
// echo this message in the form.
$msg = 'Invalid product type';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Product Entry</title>
</head>
<body>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
<select name="prodType" id="prodType">
<option value="" selected="selected">Select...</option>
<option value="general">General</option>
<option value="tools">Tools</option>
<option value="electronics">Electronics</option>
</select>
<br/><br/>
<label for="title"><strong>Product Title</strong></label>
<br/>
<input type="text" id="title" name="title" value="<?php echo $product->getTitle();?>"/>
<br/><br/>
<label for="description"><strong>Description</strong></label>
<br/>
<input type="text" id="description" name="description" value="<?php echo $product->getDescription();?>"/>
<br/><br/>
<label for="price"><strong>Price</strong></label>
<br/>
<input type="text" id="price" name="price" value="<?php echo $product->getPrice();?>"/>
<br/><br/>
<!--For Tools -->
<label for="shipper"><strong>Shipper Info</strong></label>
<br/>
<select name="shipper" id="shipper">
<option value="none" selected="selected">--</option>
<option value="usps">USPS</option>
<option value="fedex">FedEx</option>
<option value="ups">UPS</option>
</select>
<br/><br/>
<label for="weight"><strong>Weight</strong></label>
<br/>
<input type="text" id="weight" name="weight" value="<?php echo $tool->getWeight();?>"/>
<br/><br/>
<!--For Electronics -->
<label for="recyclable"><strong>Recyclable?</strong></label>
<br/>
<select name="recyclable" id="recyclable">
<option value="none" selected="selected">--</option>
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<br/><br/>
<input type="submit" id="submit" name="submit" value="Submit Product"/>
</form>
</body>
</html>
Note: You should use and learn composer. It is a must have tool to autoload your class files.
This is my view:
<form action="HomeController.php" method="post">
Available Batches:<select name="batch">
<?php mysql_connect('localhost','root','');
mysql_select_db('login');
$sql = "SELECT b_id FROM batch where type='C#'and seats_left!=0";
$result= mysql_query($sql);
while ($row = mysql_fetch_array($result)){
?>
<option value="" ><?php echo $row["b_id"];?></option>
<?php
}
?>
</select><br>
<input type="submit" name="new" value="new"><br>
</form>
<?php echo form_open('HomeController/Enteringdata') ?>
Enter batch id:<input type="text" name="b"><br>
<input type="submit" name="enter" value="enter"><br>
This is my controller:
public function Enteringdata() {
if($this->input->post('enter')=="enter"){
$b= $this->input->post('b');
$this->load->Model('LoginModel');
$seats=$this->LoginModel->batch($b);
$seats--;
$this->LoginModel->ins($seats,$b);
}
elseif($this->input->post('new')=="new")
{
$this->load->view('batchc');
}
}
I have list of record in my index page. Now i want to search a particular record/records by choosing the category (e.g phone No, email etc).How can i do this? help..
Here is my view:
<?php
$attributes = array('class'=>'searchform', 'id'=>'searchform');
echo form_open('crud/searchCrud', $attributes);?>
<div class="formelements">
<div class="formlbl">
Search:
</div>
<div class="forminput">
<input type="text" name="searchon" id ="searchon"/>
</div>
<div class="searchtyp">
<select class="searchby" name="searchby">
<option value="0">---Select--- </option>
<option value="name">Name</option>
<option value="email">Email</option>
<option value="phone">Phone</option>
</select>
</div>
<div class="searchinput">
<input type="submit" name="search" value="Search" />
</div>
</div>
<?php echo form_close();?>
Here is My controller:
public function searchCrud()
{
$records = $this->crud_mdl->searchCrud();
foreach ($records as $record) {
echo $record->name;
}
}
Here is My Model:
public function searchCrud()
{
$searchby = $this->input->post('searchby');
$searchon = $this->input->post('searchon');
$this->db->get('test')->result();
return $this->db->like($searchon, $searchby);
}
1) You should never access POST data directly in the Model.
2) Always collect them in Controller and then pass it to the Model.
3) Also always try to create your Model functions, re-usable.
Modified your code a bit. Try running it.
Controller:
public function searchCrud()
{
$searchby = $this->input->post('searchby');
$searchon = $this->input->post('searchon');
$records = $this->crud_mdl->searchCrud($searchby, $searchon);
foreach ($records as $record)
{
echo $record->name;
}
}
Model:
public function searchCrud($searchby, $searchon)
{
$this->db->like($searchon, $searchby);
$query = $this->db->get('test');
if($query->num_rows() > 0)
return $query->result();
else
return FALSE;
}