-1

I have this Code where i would insert a group of numbers from a database into the query for the message to be sent to, by selecting a group where it contains a group of numbers and the message will be sent to the whole list of numbers in that group what im trying to do is limit the numbers being inserted in to send by another input i provide to enter the number of message i want being sent any help is kindly appreciated

if(isset($_POST[sent]) and $_POST[gid] > 0){
    $hh = 0;
    $q = mysql_query( 'select * from numbers where sid = '.$_POST[gid].' and active = 1 and  uid = ' . $_COOKIE['uid'] );
    while ( $d = mysql_fetch_array( $q ) )
    {
        $phone = $tpl['user']['usergroup']['phone'];
        $time =time();
        $hhhh = "INSERT INTO `sending` 
            (`from`, `type`, `msg`, `to`, `uid`, `gid`, `msid`, `time`) VALUES 
            ('$phone', '$_POST[type]', '$_POST[msg]', '$d[number]','$_COOKIE[uid]', '$_POST[gid]','$_POST[msid]', '$time')";
        $ggg = mysql_query($hhhh);
        //echo mysql_error();
        $hh++;
    }
    $tpl['msg'] = "<div class='alert alert-succes' style='color:green'>
kero
  • 10,647
  • 5
  • 41
  • 51
  • hard to follow exactly what you want to limit. Question not very clear – charlietfl May 29 '14 at 11:56
  • Your code is widely open to SQL injection attacks! Please also be aware that the mysql extension (supplying the mysql_ functions) has been deprecated since 2012, in favor of the mysqli and PDO extensions. It's use is highly discouraged. See http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php – Oldskool May 29 '14 at 12:13

1 Answers1

0

Try this.

    $q = mysql_query( 'SELECT * FROM NUMBERS WHERE sid = '.$_POST[gid].' AND active = 1 AND  uid = ' . $_COOKIE['uid'].' LIMIT 0, 100' );

This will limit your results to the first 100 results. Hope it helps.

S8tan
  • 3
  • 1