$ip_sql=mysql_query("select ip_id from vote_ip where mes_id_fk='1' and ip_add='$ip'"); $count=mysql_fetch_array($ip_sql); 

In general, it is necessary for select take 10 ip_id , where mes_id_fk= from 1 to 10.

    3 answers 3

     select ip_id from vote_ip where (mes_id_fk BETWEEN 1 AND 10) and ip_add='$ip' 

    or

     select ip_id from vote_ip where mes_id_fk < 10 and ip_add='$ip' 
    • Yes, what you need! Even if there are all 10 lines, then the query will take 10 values ​​to the array, and if, for example, there are no 3 values, the array will turn out from 7, and it’s necessary that where no values should give 0. - Ruslan Librovsky
    • for using between +1) It did not occur at the time of writing the answer :). Well, the variant with IN () works in the same way :) - draev
     $ip_sql=mysql_query("select ip_id from vote_ip where mes_id_fk IN('1','2','3','4','5','6','7','8','9','10') and ip_add='$ip' LIMIT 10"); $count=mysql_fetch_array($ip_sql); 
    • Doesn't the sql query fit you? - draev
    • Array ([0] => 1 [ip_id] => 1) it turns out not massive)) - Ruslan Librovsky

    Something hardly understood the question, but! In the mysql_query query, add such things as ORDER BY and LIMIT . The output of data to carry out through the cycle:

     while($count=mysql_fetch_array($ip_sql)) { echo $count['И нужное поле из бд']; } 

    PS Or I did not understand well)

    • You need to select 10 values, where everyone has the same IP(ip_add) , but different mes_id_fk . Moreover, mes_id_fk strictly defined. In general, it is necessary for voting to know if the user answered the given question. - Ruslan Librovsky September