I am new to PHP / sql, but I can not know why this function is not returning to anyone Sorting array This is returning the right result, but they are not sorted.
Product ID Back Product Information Work Product Product ($ pid) {$ $ sql; $ Query = "SELECT * product from WHERE product_id = '$ pid' ORDER by 'P_Name'"; $ Result = mysqli_query ($ sql, $ query); $ Array = array (); If (mysqli_num_rows ($ result) & lt; 1) {echo mysqli_error ($ sql); } // end if other {while ($ line = mysqli_fetch_array ($ result)) {array_push ($ array, $ line ['product_ID']); Array_push ($ array, $ line ['P_Name']); Array_push ($ array, $ line ['Charge_Desc']); Array_push ($ array, $ line ['lower_grace']); Array_push ($ array, $ line ['hyperbolic']); Array_push ($ array, $ line ['link']); Array_push ($ array, $ line ['description']); } // END WHILE} // END ELSE $ return; } / / END function
Edit: MySQL query has been changed for the code below, still not getting a serial array.
$ query = "SELECT * FROM product WHERE Product_ID = '$ pid' ORDER BY P_Name ASC"
option ORDER BY 'P_Name'
, otherwise you can use that column as ORDER BY < / Code>.
You can avoid your $ pid
variable with the same '
Remove them and they will work
After that, you With a statement prepared for security reasons, it will be rewritten :)
And as stated in the comments, if you want to avoid the reserved word, which is the name of a column, Can use
Comments
Post a Comment