Jump to content

unxposed

Members
  • Posts

    46
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

unxposed's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi, Thanks for the reply. I'm actually doing this directly in phpmyadmin so definately a sql issue. Here's the exact code: SELECT parties.id, GROUP_CONCAT(DISTINCT CONCAT(people_lang.name, ' - ', IFNULL(members_lang.position, 'Position unknown')) SEPARATOR '~') AS position FROM parties LEFT JOIN members ON parties.id = members.party LEFT JOIN members_lang ON members.id = members_lang.member AND members_lang.il8n = 1 LEFT JOIN people_lang ON members.person = people_lang.person AND people_lang.il8n = 1 And the result: Hla Myint Oo - Position unknown~Htay Win - Position unknown~Maung Oo - Position unknown~Thura Shwe Mann - Position unknown~Thiha thura Tin Aung Myint Oo - Position unknown~Khoo Francis Ko - candidate~Soe Maw Ye - Position unknown~Shwe Nan - Position unknown~Saw Htay - Position unknown~Kyaw Aye - Position unknown~Moe Myint Thein - Position unknown~San Htun - Position unknown~Maung Maung Oo - Position unknown~Win Myint Dr USDP - Position unknown~Soe Aung - Position unknown~Htay Maung - Position unknown~Khin Maung Htay 2 - Position unknown~Mat Gyi USDP - Position unknown~Tin Kha - Position unknown~Nu USDP - Position unknown~Tin Yu - Position unknown~Shwe Aung USDP - Position unknown~Nyunt Tin - Position unknown~Maung Thin Dr - Position unknown~Zin Nyunt - Position unknown~Win Naung - Position unknown~Myo Thant Tin Dr - Position unknown~Mya Nyein - Position unknown~Myint Kyi Dr - Position unknown~Khin Shwe Dr - Position unknown~Aye Maut - Position unknown~Than Soe - Position unknown~Thein Aung USDP - Position unk Thanks
  2. I have a query where I have a concat nested inside a group concat. The problem I'm having is that the last x amount characters are being cut from the result. for example below at the end of the position column instead of finishing 'Position unknown' it finsihes 'Position'? GROUP_CONCAT( DISTINCT CONCAT( people.name, ' - ', IFNULL(members.position, 'Position unknown') ) SEPARATOR '~' ) AS position Thanks
  3. Hi, I have a database with numbers/dates etc stored. I am creating a multilingual site, in both English and Burmese/Myanmar. Burmese/Myanmar has a different alphabet - a bit like Chinese/Thai. The database is set up nicely to allow text translations, but I am having a problem with numbers. How would I go about printing a number/date in Burmese script from a datebase stored as numeric values - i.e.int?? Database etc. is all utf8. Thanks.
  4. Hi, Would anybody be able to tell me why I'm getting an error here? Am I not able to use 2 group_concats in the same query? SELECT GROUP_CONCAT(links.title ORDER BY block_links.weight SEPARATOR ', ') AS links, GROUP_CONCAT(links.url ORDER BY block_links.weight SEPARATOR \', \') AS urls FROM blocks LEFT JOIN block_links ON blocks.block_id = block_links.block_id LEFT JOIN links ON block_links.link_id = links.link_id WHERE blocks.block_id IN (4) GROUP BY blocks.block_id Thanks in advance
  5. Oh my god yes yes yes! Thank you. It seems so obvious now... but I've spent hours and hours of my life trying to work that out!
  6. I guess to simply this to find out where I'm going wrong - I'm basically trying to get the value 'Hello world' out of the following function: function test($i) { $i++; if ($i == 1) { $return = test($i); } elseif ($i == 2) { $return = test($i); } else { return 'Hello world'; } } $return = test(0); echo $return; I've tried only naming the first as a variable, the last, all of them, giving them different variable names... but no luck! Thanks!
  7. I think it definately has something to do with the function looping within itself. Which of the functions do I need to define as the variable I wish top print further down the page $return. The first function, all of them, the last one? It seem logical that it would be the last one - which modifying the code here would produce: $j++; if (($j + 1) < count($sub_directory)) { folder_array($array_depth, $j, $sub_directory, $current_directory); } elseif ($j < count($sub_directory)) { $return = folder_array($array_depth, $j, $sub_directory, $current_directory); } else { /* Test print the array - WORKING */ print_r($array_depth); /* Return the array */ return array($array_depth, $current_directory); } But then again setting all of the functions as the same variable, I'd just assume the variable would keep getting overrided with the last function output. So that would be equally as logical. As I guess would be setting the first function only as the variable, as all other functions are within this!
  8. So what should be happening there is that that I have the fuction within itself, and it's repeated indefinately until that conditional is not true. Each time adding new values to the $array_depth array. When that conditional is not true then the return should be set inside the final function. Does that make sense?
  9. Hi guys, I've been struggling all day with this function and I think I'm there, it's just now I can't get the value of the array out of the function to use further down my page. Which I can print within the function and returns perfectly. I'd really appreciate a little help. Thanks. function folder_array($array_depth, $j, $sub_directory, $current_directory) { if ($j == 0) { foreach ($array_depth as $key => $value) { if ($value == $sub_directory[0]) { $array_depth[$sub_directory[0]] = array(); if ($handle = opendir($current_directory)) { while (false !== ($file = readdir($handle))) { if ((!strpos($file, '.')) && ($file !== '.') && ($file !== '..')) { $array_depth[$sub_directory[0]][$file] = $file; } } closedir($array_depth); } } } } elseif ($j == 1) { foreach ($array_depth[$sub_directory[0]] as $key => $value) { if ($value == $sub_directory[1]) { $array_depth[$sub_directory[0]][$sub_directory[1]] = array(); if ($handle = opendir($current_directory)) { while (false !== ($file = readdir($handle))) { if ((!strpos($file, '.')) && ($file !== '.') && ($file !== '..')) { $array_depth[$sub_directory[0]][$sub_directory[1]][$file] = $file; } } closedir($array_depth); } } } } elseif ($j == 2) { foreach ($array_depth[$sub_directory[0]][$sub_directory[1]] as $key => $value) { if ($value == $sub_directory[2]) { $array_depth[$sub_directory[0]][$sub_directory[1]][$sub_directory[2]] = array(); if ($handle = opendir($current_directory)) { while (false !== ($file = readdir($handle))) { if ((!strpos($file, '.')) && ($file !== '.') && ($file !== '..')) { $array_depth[$sub_directory[0]][$sub_directory[1]][$sub_directory[2]][$file] = $file; } } closedir($array_depth); } } } } $j++; if ($j < count($sub_directory)) { $return = folder_array($array_depth, $j, $sub_directory, $current_directory); } else { /* Test print the array - WORKING */ print_r($array_depth); /* Return the array */ return $array_depth; } } folder_array($form[folders], 0, $form[sub_directory], $form[current_directory]); /* Print the returned array - NOT WORKING */ print_r($return);
  10. Ooops. Thanks for that, I probably should have known that... but I just didn't!!! Thanks again.
  11. Okay so can't get my head around this. I have a query: INSERT INTO pages (parent_id, layout_id, clean_url, title, description, keywords, live, language_id, navigation, weight , created, created_by, modified, modified_by) VALUES ('1', '1', '/boooo', 'booooooo', 'hello', '', '1', '3', '1', '0' , NOW(), 1, NOW(), 1) It works okay and inserts a row, but if I use mysql_num_rows I don;t get any valuem it returns blank. Therefore when I use it here: if (mysql_num_rows($result) >= 1) { do this } else { do that } It always goes to else. Also when I try and manually insert the query through phpmyadmin it inserts, but I don;t get the green bar returned saying it's been inserted and giving details of the query!? Weird, or am I just being stupid? Help would be really appreciated. Thanks.
  12. SELECT users.name, GROUP_CONCAT(relationships.name SEPARATOR ', ') FROM users LEFT JOIN user_relationships ON users.user_id = user_relationships.user_id LEFT JOIN relationships ON user_relationships.rel_id = relationships.rel_id GROUP BY users.name
  13. Hi, I have three tables: users (cols: user_id, name) relationships (cols: rel_id, name) user_relationships (cols: id, user_id, rel_id) My current sql is: SELECT users.name, relationships.name AS relationship FROM users LEFT JOIN user_relationships ON users.user_id = user_relationships.user_id LEFT JOIN relationships ON user_relationships.rel_id = relationships.rel_id Which returns along these lines: name relationship bob user mary user mary friend mary associate My question is: How can I change this query to return something like this?: name relationship bob user mary user, friend, associate Thanks in advance!
×
×
  • 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.