php - post rating for an individual item in a list using codeigniter -
i’m having heck of time figuring out how post rating individual item in list of items,
this code let’s me rate multiple items, not single items:
for($i=0;$i<2;$i++){ $doc_item_id = $_post['item_id0'][$i]; $doc_rating = $_post['document_rating'][$i]; $it_rt = array( 'item_id' => $doc_item_id, 'rating' => $doc_rating, ); $this->purchases_model->update_document($it_rt); } whereas code let’s me rate first item (or last item depending on put "break;"):
foreach($_post['item_id0'] $doc_item_id){ foreach($_post['document_rating'] $doc_rating){ } break; } $it_rt = array( 'item_id' => $doc_item_id, 'rating' => $doc_rating, ); $this->purchases_model->update_document($it_rt); any thoughts on how correct either of these such user rate individual item of choosing appreciated,
if user supposed choose item rate (instead of rating items @ same time), should allow him (showing 1 item, let him select 1 using radio buttons...), , should able, php side, retrieve index of item modify.
finally, in order modify 1 item, code should (php side, have update html form well)
$i = $_post['item_index']; // here i'm supposing have added radio buttons // named 'item_index' allow user choose item rate $doc_item_id = $_post['item_id0'][$i]; $doc_rating = $_post['document_rating'][$i] ; $it_rt = array( 'item_id'=> $doc_item_id, 'rating' => $doc_rating, ); $this->purchases_model->update_document($it_rt); in fact original code without for loop.
Comments
Post a Comment