I need one help. I need to push single row table value into array using PHP and MySQL. I am explaining my table below.
db_tc
id tc1 tc2 tc3 tc4 tc5 tc6 tc7 tc8 tc9 tc10
1 aa bb cc dd ee ff gg hh jj
Here I need need to push all column value to single array and using same key name. I am explaining my code below.
$faqquery="select * from db_tc order by id desc limit 1";
$faqdata= $this->modl_obj->db_get_data($faqquery);
$ctr=count($faqdata);
$tcArr=array();
if($ctr >0){
foreach ($faqdata as $v) {
}
}
Here which column has blank data that will not push into array. My expected output should like below.
$tcArr=[{'tc':'aa'},{'tc':'bb'},{'tc':'cc'},{'tc':'dd'},{'tc':'ee'},{'tc':'ff'},{'tc':'gg'},{'tc':'hh'},{'tc':'jj'}]
Please help me to resolve this problem.
tcdata violates the Zero, One or Infinity Rule of database normalization. A proper relational structure would be easier to deal with, you'd insert one record for each element of$tcArr.