Jump to content


Photo

MySQL Syntax problem...


  • Please log in to reply
2 replies to this topic

#1 Germaris

Germaris
  • Members
  • PipPipPip
  • Advanced Member
  • 97 posts
  • LocationCanada

Posted 20 October 2006 - 08:08 PM

Hi there!

This is a query of a PHP script I wrote which is supposed to return the number of rows for each different object present in the field nammed "list"

$query="SELECT list, count( * ) AS n FROM $table GROUP BY list HAVING ( n > 1 )";
//I don't know how to write the following
print (
// ? ? ? ? ? 
);

The result returned by this query is, FOR EXAMPLE, something like this

list    n
_____________
ai      72
bg      325
he      127
etc...

I want to send this result to my Flash file

&ai=72
&bg=325
&he=127
etc...

but I don't know to write it the right way !!!

Many thanks in advance for your help !

#2 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 20 October 2006 - 09:16 PM

<?php
$str = "SELECT list, count( * ) AS n FROM $table GROUP BY list HAVING ( n > 1 )";
$query = msyql_query($str);

while($result = mysql_fetch_array($query, MYSQL_ASSOC)) {
  echo "{$result['list']} {$reseult['count(*)'} <br />";
}
?>

Try that :)

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 22 October 2006 - 08:12 PM

You should probably build an array and join it with ampersands.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users