Hi, I am working on a script where I want to select parent id for a new user and save his parent id along with parents parent ids in mysql table.
$last_id = mysql_insert_id(); //select parent id of last inserted user $sel = mysql_query("SELECT * FROM tbl_new_agent WHERE new_agnt_id = '".$last_id."'"); $row = mysql_fetch_array($sel); $a = $row['new_agnt_ParentId']; //select parents of parent which are supposed to be stored at parent_arr field in db as comma separated values $sel1 = mysql_query("SELECT * FROM tbl_new_agent WHERE new_agnt_id = '".$a."'"); $row1 = mysql_fetch_array($sel1); //here i want to add element in array.though its not working obviously $b = array_push($row1['parent_arr'],$a); $update = mysql_query("UPDATE tbl_new_agent SET parent_arr = '".$b."' WHERE new_agnt_id = '".$last_id."'");
I have no idea how I can store comma separated values or store a single value initially and then add more elements.Can anyone give me idea in this regard?