php - Trying to create a function using mysql_fetch_array -


my aim send pushbullet notifications users using cron.

i have mysql db , there users table , issues table in it. want users users table after create query bring issue count based on assigned user id issues table. make notifications.

here details , tried. firstly; tried user ids , worked expected.

   function some_function($sa){    foreach($sa $s)       echo $s;  }  $sqltext['id']="select users.id,                  users.login                 users                 group users.login";      $sqlquery_mainmenu = mysql_db_query($db, $sqltext['id'], $connection) or die("error");     $file_names=array();     while($mm_content=mysql_fetch_array($sqlquery_mainmenu)){         $users[]=$mm_content["id"];     }        foreach ($users $user) {         $foo=array($user);         some_function($foo);     } 

since have user ids tried create new query brings issue count based on user id. not it. know want not know how it.

$sqltext['push']="select count(*) issues inner join users on issues.assigned_to_id = users.id assigned_to_id = $s";      $sqlquery_mainmenu = mysql_db_query($db, $sqltext['push'], $baglanti) or die("error");     $users=array();     while($mm_content=mysql_fetch_array($sqlquery_mainmenu)){         $users[]=$mm_content;     }        foreach($users $index => $user){         //$attachment .= $directory.'/'.$files[$index].', '."'$file_names[$index]'";         echo $user[0] ;          } 

basically trying create function runs following line each value came mysql.

$pb->device('user.id db')->pushlink("some text", "http://some link", "issue count"); 

what suggest don't need initial query. assume case not need send notifications users no issues, can user ids directly issue table without querying user table first.

$sql = "select assigned_to_id user_id, count(*) issue_count     issues group assigned_to_id"; 

(if need additional information user table, can still 1 query joining 2 tables together.)

after execute query, should able whatever notification method fetch records results.

$users_with_issues = mysqli_query($db, $sql); while($user = mysqli_fetch_assoc($users_with_issues)){     $pb->device($user['user_id'])->pushlink(         "some text", "http://some link", $user['issue_count']); }    

i used mysqli in example, same general approach should work regardless of database extension using.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -