Welcome Guest, Not a member yet? Register   Sign In
Using Left in mysql querys problem accessing results
#1

[eluser]jon29[/eluser]
hi i'm converting one of my sites from procedural php to codeigniter and having trouble when i use LEFT to restrict number of characters returned, query runs fine but as it returns an array key of LEFT(content, 220) i can't access it as normal in the views section again then same problem with the date,

could someone offer advice on the best way round this please?


Code:
function newspreview()
{
$sql = "SELECT id, title, LEFT(content, 20), DATE_FORMAT(date, '%d-%m-%Y') FROM newsletter ORDER BY date DESC LIMIT 3" ;
$q = $this->db->query($sql);
  if($q->num_rows() > 0) {
   foreach ($q->result_array() as $row) {
    $data[] = $row;
   }
   return $data;
  }  
  
}

returns

Array ( [0] => Array (
[id] => 4
[title] => Page
[LEFT(content, 20)] => What are pleased to a
[DATE_FORMAT(date, '%d-%m-%Y')] => 12-01-2012
)

any advice very much appreciated thanks


Messages In This Thread
Using Left in mysql querys problem accessing results - by El Forum - 02-22-2012, 09:52 AM
Using Left in mysql querys problem accessing results - by El Forum - 02-22-2012, 10:08 AM
Using Left in mysql querys problem accessing results - by El Forum - 02-22-2012, 10:10 AM
Using Left in mysql querys problem accessing results - by El Forum - 02-22-2012, 10:25 AM
Using Left in mysql querys problem accessing results - by El Forum - 02-22-2012, 05:36 PM
Using Left in mysql querys problem accessing results - by El Forum - 02-22-2012, 05:50 PM
Using Left in mysql querys problem accessing results - by El Forum - 02-22-2012, 06:33 PM
Using Left in mysql querys problem accessing results - by El Forum - 02-27-2012, 05:43 PM



Theme © iAndrew 2016 - Forum software by © MyBB