2016-10-11 7 views
0

jpgraph를 사용하여 차트를 생성합니다. 나는 성공적으로 데이터베이스에서 음모에 대한 데이터를 얻고 나는 또한 제목을 데이터베이스에서 가져 가고 싶습니다. 나는 이미이 스크립트를 사용하고 있습니다.mysql 데이터베이스에서 JPGraph에 제목을 추가하는 방법

$sql = $this->db->select("title from table")->get()->first_row(); 
$title = $sql->title; 
$graph->title->Set($title); 

하지만 작동하지 않습니다. 누구든지이 문제를 해결할 수 있습니까? 당신이

+0

답변을 확인 했습니까? – devpro

+0

네, 그렇지만 작동하지 않습니다. –

+0

결과를 에코하십시오 $ echo-> exit;'이 줄 앞에 제목을 가져 오는 지 여부'$ graph-> title-> Set ($ title);' – devpro

답변

0

이 FIRST_ROW 필드와 함께 얻을하는 데 도움이 될 것입니다 감사합니다 :

$this->db->select('title'); // your column 
$this->db->from('table'); // your table 
$result = $this->db->get()->result(); // get result 
$title = $result->first_row()->title; // get ist row using first_row with your field name 
$graph->title->Set($title); // as you are using for graph 

은 또한 점에 유의, CI 기능 row() 또한 객체 형태로 쿼리의 인도 표준시 행을 반환합니다. 수동에서

:

You can walk forward/backwards/first/last through your results using these variations:

$row = $query->first_row() 
$row = $query->last_row() 
$row = $query->next_row() 
$row = $query->previous_row() 

또는 당신은 당신이 좋아, PARAM 같은 단어 '배열'을 사용할 수있는 것보다 대신 객체의 배열에 결과를 인쇄 할 경우 :

$query->first_row(‘array’) 

더 잘 이해하려면 CI 설명서를 참조하십시오. http://www.codeigniter.com/userguide3/database/results.html