shaymiller
Regular Member
- Dec 3, 2016
- 456
- 45
I don't know why my INSERT sql using posting one item only, not all the results from another query
Below is my code to see what I am saying
Below is my code to see what I am saying
Code:
<?php
// Declaring Database connection variables
echo "<font color=green><B>Connected successfully</font></b> <BR>";
// Getting From WordPress Database
$WP_SQL = "
SELECT id, name, rank, count, pagenumber FROM todaytop WHERE id > '0'
ORDER BY
id DESC
LIMIT
40
";
$WP_QUERY = mysqli_query($con, $WP_SQL);
// output data of each row
$WP_RESULT = mysqli_fetch_all($WP_QUERY, MYSQLI_ASSOC);
require('get_google_image.php');
$counter = 1;
foreach ($WP_RESULT as $result) {
echo "-============================================================-<br/>";
echo "Starting Processing On " . $counter . " Result...<br/>";
echo "<pre>";
print_r($result);
echo "</pre>";
$resulter = null;
// $artist_name = $search_query = "Hollywood " . $result['name'];
$artist_name = $search_query = "Hollywood ";
$search_query = urlencode($search_query);
$artist_name3 = $result['name'];
$GOOGLE_IMAGE = new get_google_image_class;
$GOOGLE_IMAGE->limit = 1;
$GOOGLE_IMAGE->display = false;
$GOOGLE_IMAGE->GetImage($search_query);
$image_url = $GOOGLE_IMAGE->imageUrl;
echo "Google Image Founded " . $image_url;
//
// echo "<pre>";
// print_r($image_url);
// echo "</pre>";
//$image_url1 = $GOOGLE_IMAGE->GetImage($search_query);
//name = '%s'
$CHECK_IN_TABLE = sprintf("
SELECT latestip_bsong.todaytop.name AS bSONG_name, latestip_vk.tracks.name AS PG_Name, latestip_vk.tracks.id AS TRACK_ID, latestip_bsong.todaytop.release_date AS release_date, latestip_bsong.todaytop.rank AS RANK, COUNT(latestip_vk.tracks.name) AS num
FROM latestip_bsong.todaytop, latestip_vk.tracks
WHERE latestip_bsong.todaytop.name = latestip_vk.tracks.name
GROUP BY latestip_vk.tracks.name HAVING (num < 2)
", mysqli_real_escape_string($con, $artist_name3));
echo "Executing This query to get Result for respective artist <br/>";
echo "<strong> " . $CHECK_IN_TABLE . "</strong><br/>";
$CHECK_QUERY = mysqli_query($con, $CHECK_IN_TABLE);
$resulter = mysqli_fetch_assoc($CHECK_QUERY);
echo "THE RESULT FOUND IS BELLOW: <br/>";
echo "<pre>";
print_r($resulter);
echo "</pre>";
echo "<strong>" . count($resulter) . "</strong> result(s) found for this Query <br/>";
if (count($resulter) > 0) {
$action = "<font color=green><B>Inserted</font></b>";
$QUERY = sprintf("INSERT INTO `channelables` (`id`, `channel_id`, `channelable_type`, `channelable_id`, `order`) VALUES (NULL, '9', 'App\\\\Track', '" . $resulter['TRACK_ID'] . "', '" . $resulter['RANK'] . "');", mysqli_real_escape_string($con, $image_url));
echo "This query is now preparing...<br/><BR>
";
echo "<strong>" . $QUERY . "</strong> <br/>";
$PREPARE = mysqli_query($con, $QUERY);
if (!$PREPARE) {
echo "<BR> <strong style='color:red'># 1 ERROR FOUND IN " . $QUERY . "</strong><br/>";
echo "<pre>";
print_r(mysqli_error($con));
echo "</pre>";
}
} else {
$action = "<font color=green><B>Inserted</font></b>";
echo "This query is now preparing...<br/>";
echo "<strong>" . $QUERY . "</strong> <br/>";
$PREPARE = mysqli_query($con, $QUERY);
if (!$PREPARE) {
echo "<BR> # 2 <strong style='color:red'>ERROR FOUND IN " . $QUERY . "</strong><br/>";
echo "<pre>";
print_r(mysqli_error($con));
echo "</pre>";
}
}
echo $action . ' the Artist : <strong>' . $artist_name3 . '</strong> with the following image<br/>';
echo "<pre>";
print_r($QUERY);
echo "</pre>";
echo "=================================================================================================";
echo "<br>";
$counter++;
}
// Closing connection
$conn = null;
[/quote]