Jump to content

undersun

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by undersun

  1. Thank you BlueSkyIS. Using var_dump($tmp_name) the output was: array(6) { [0]=> string(6) "Name A" [1]=> string(6) "Name B" [2]=> string(6) "Name C" [3]=> string(6) "Name D" [4]=> string(6) "Name E" [5]=> string(6) "Name F" } And using var_dump($details) the output was: (I added the line breaks) array(6) { [0]=> array(3) { [0]=> string(2) "62" [1]=> string(6) "Name A" [2]=> string(1) "1" } [1]=> array(3) { [0]=> string(2) "65" [1]=> string(6) "Name B" [2]=> string(1) "1" } [2]=> array(3) { [0]=> string(2) "56" [1]=> string(6) "Name C" [2]=> string(1) "1" } [3]=> array(3) { [0]=> string(2) "41" [1]=> string(6) "Name D" [2]=> string(1) "1" } [4]=> array(3) { [0]=> string(2) "64" [1]=> string(6) "Name E" [2]=> string(1) "0" } [5]=> array(3) { [0]=> string(2) "43" [1]=> string(6) "Name F" [2]=> string(1) "0" } } Is the "Array sizes are inconsistent" error thrown up because $details is a multi-dimensional array while $tmp_name isn't ??
  2. I've reread the PHP manual for 'array_multisort' (http://php.net/manual/en/function.array-multisort.php) and I still can't see what I've done wrong. The actual code seems to work on the site but every time it's run it throws up an error and it's filling up my error logs. DOes anyone know why it would report a 'Array sizes are inconsistent' error?
  3. Hi, I'm trying to combine and sort two tables so I can display the output as one. And I'm getting the error "PHP Warning: array_multisort() [<a href='function.array-multisort'>function.array-multisort</a>]: Array sizes are inconsistent in ... on line 282". Line 282 is "array_multisort($tmp_name, SORT_ASC, $details);". I'm a self taught beginner coder and I know that my coding is often very clumsy and so that is probably the problem. Any help to solve this error would be greatly appreciated. Cheers $sql = "SELECT * FROM db_user LEFT JOIN db_details ON db_details.details_id = db_user.user_details_id WHERE db_user.user_id = '" . $user_id . "'"; $result = mysql_query($sql); $num = mysql_num_rows($result); if ($num != NULL) { for ($i = 0; $i < $num; $i++) { $user_group_id = mysql_result($result, $i, "db_user.user_group_id"); $details_id = mysql_result($result, $i, "db_details.details_id"); $details_name = mysql_result($result, $i, "db_details.details_name"); $details[] = array($details_id, $details_name, $user_group_id); } } $sql = "SELECT * FROM db_members LEFT JOIN db_details ON db_details.details_id = db_members.members_details_id WHERE db_members.members_user_id = '" . $user_id . "'"; $result = mysql_query($sql); $num = mysql_num_rows($result); if ($num != NULL) { for ($i = 0; $i < $num; $i++) { $members_group_id = mysql_result($result, $i, "db_members.members_group_id"); $details_id = mysql_result($result, $i, "db_details.details_id"); $details_name = mysql_result($result, $i, "db_details.details_name"); $details[] = array($details_id, $details_name, $members_group_id); } } foreach ($details as $key => $val) { $tmp_name[$key] = $val[1]; } array_multisort($tmp_name, SORT_ASC, $details);
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.