How to search php array for all items from mysql table?
I want to display only usernames that doesn't exist in usernameArray and
only exist in mysql table. in another word for each username in mysql
table i want to check it inside usernamesArray and if doesn't exist in
that array i just output that username from mysqltable? could anyone show
me how i can achieve this task.Thanks
$url =
"https://api.instagram.com/v1/users/XXXX/follows?access_token=XXXX&count=-1";
$api_response = get_data(''.$url);
$record = json_decode($api_response); // JSON decode
$m = 0;
$usernamesArray = array();
foreach($record->data as $user) // each user data (JSON array) defined as
$user
{
$m++;
$usernameVar = $user->username;
$usernamesArray[] = $usernameVar;
}
print_r($usernamesArray);
$sql->Query("SELECT * FROM mytable");
echo "Total:".$sql->rows;
echo "<br>";
for ($i = 0; $i < $sql->rows; $i++)
{
$sql->Fetch($i);
$id = $sql->data[0];
$username = $sql->data[1];
$website = $sql->data[2];
$profile_picture = $sql->data[3];
//now compare usernamesArray with current data in mysql table and only
display
//the usernames that doesnt exist in usernamesArray?
echo("<div id='grid-cell' style='padding:5px'><a
style='text-decoration:none' href='$username'><img class='photo-grid'
src='$profile_picture' width=150 height=150 title='$username' /></a><div
class='moreInfo2'><a style='color:#000;text-decoration:none'
href='/$username' target='_blank'>$item:$username()</a></div></div>\n");
}
No comments:
Post a Comment