Jump to content

Angela

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Angela's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Now it works [code]<? print mysql_num_rows(mysql_query("SELECT DISTINCT country FROM ".C_MYSQL_MEMBERS)); ?>[/code] thank you shoz! How to mark this thread resolved? I'm new here...
  2. Sorry... not works. Need just total of countries. I have countries and people from countries "c" (code is above). ex: Germany 2 USA 4 UK 7 etc. need just count how many countries are there in total and echo it.
  3. [!--quoteo(post=375770:date=May 21 2006, 10:09 AM:name=shoz)--][div class=\'quotetop\']QUOTE(shoz @ May 21 2006, 10:09 AM) [snapback]375770[/snapback][/div][div class=\'quotemain\'][!--quotec--] [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] [color=blue]COUNT[/color]([color=green]DISTINCT[/color] country) [color=green]FROM[/color] [color=orange]table[/color] [!--sql2--][/div][!--sql3--] You could also modify your existing query to retrieve the total in addition to the indvidual counts using [a href=\"http://dev.mysql.com/doc/refman/4.1/en/group-by-modifiers.html\" target=\"_blank\"]ROLLUP[/a] (added in MYSQL 4.1.1). You wouldn't be able to use ORDER BY however and would need to use PHP to do the sorting. [/quote] How to echo it?
  4. This code gives country and number of people from country "c": [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$tmp=mysql_query("SELECT country, count(*) as c FROM ".C_MYSQL_MEMBERS." group by country order by country asc"); while($i=mysql_fetch_array($tmp)) { <?=$wcr[$i['country']]?><?=$i['c']?> }[/quote] Need count how many countries are there (total). Please help.
  5. [!--quoteo(post=373274:date=May 11 2006, 08:00 AM:name=ober)--][div class=\'quotetop\']QUOTE(ober @ May 11 2006, 08:00 AM) [snapback]373274[/snapback][/div][div class=\'quotemain\'][!--quotec--] Why are you printing an entire array repeatedly that doesn't have ANYTHING to do with the foreach loop? [/quote] I don't know. ober please tell me what can i do?
  6. It works when: [code]<? foreach($wcr as $key=>$value) { print_r ($i['country']); }?>[/code] but need some correcting in code, because prints as key too many copies like this: 77777777777777777777....7 How to change that get without copies? Maybe someone can help...
  7. [!--quoteo(post=373248:date=May 11 2006, 06:55 AM:name=hvle)--][div class=\'quotetop\']QUOTE(hvle @ May 11 2006, 06:55 AM) [snapback]373248[/snapback][/div][div class=\'quotemain\'][!--quotec--] I suppose you have the country name, and you need to find out key location. Here is one way to do it: $country = "Germany"; // say you want to find key location for Germany foreach ($wcr as $key=>$val) { if ($val == $country) return $key; } [/quote] Yes, you are right it so easy, but just courious - NOT WORKS :-( no results
  8. [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]foreach ($wcr[$i] as $key=>$value): echo $key[$i]; endforeach;[/quote] not works again : Invalid argument supplied for foreach() [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?=$i['country']?> [/quote] - get no results What i need: [code]<?=$wcr[$i['country']]?> [/code]- it gets value from array (i.e. Germany) Need to get ONLY Array key. i.e number for Germany in array $wcr. Then need no echo, i want to insert this varable into link [code]<A href="http://someurl.com/search.php?from=0&amp;country=0"><?=$wcr[$i['country']]?></A>[/code] Now country=0. need to change it, when country will change.
  9. Not works. Thanks anyway. I need not echo, just how to retreive as Array keys - 0, 1, 2 etc (not their values -Albania, etc).
  10. [code]<?=$wcr[$i['country']]?>[/code] This code prints country name from Array [code]$wcr=array( 'All countries', 'Albania', .... etc ... ...' );[/code] Need to print only value from Array (0, 1, etc.) not country name. How i must change code? Thank you in advance. Angela
  11. [!--quoteo(post=372142:date=May 7 2006, 06:00 PM:name=SemiApocalyptic)--][div class=\'quotetop\']QUOTE(SemiApocalyptic @ May 7 2006, 06:00 PM) [snapback]372142[/snapback][/div][div class=\'quotemain\'][!--quotec--] I don't think your syntax is correct here, well, I have never seen ternary expressions written like that before... [code]$mpurpose = (!empty($purpose)) ? " AND purposes = '".$purpose."'" : "";[/code] [/quote] Yes, it is correct it works, but i need help of person with knowledge of such things.
  12. Here is piece of code: [code]!empty($purpose) ? $mpurpose=" AND purposes = '".$purpose."'" : $mpurpose = ""; !empty($marstat) ? $mmarstat=" AND marstat = '".$marstat."'" : $mmarstat = "";[/code] It gives search results from 2 selectboxes "purpose" and "marstat". How to change first line - that when only "purpose" is selected to see in search results for both values: "purpose" +(or) "marstat"?
×
×
  • 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.