i need to loop through a table of myn, check one of its columns(id) during each row and match these id values in a another table to obtain the value known as useragent from it.
but currently theres something wrong with my while loop this only checks the id value of the first row only(it does not keep on checking every row)
$myarray = mysql_query("SELECT * FROM table_105");
while($row = mysql_fetch_array($myarray)){
$table = 'table_105';
$update = mysql_query("SELECT id as unp FROM $table");
$col = mysql_fetch_assoc($update);
$col_id = ($col["unp"]);
$var1 = mysql_query("SELECT useragent as ua FROM paneltb WHERE id = $col_id");
$col3 = mysql_fetch_assoc($var1);
$col_ua = ($col3["ua"]);
$browser = get_browser($col_ua, true);
$platform = $browser['platform'];
$device_name = $browser['device_name'];
$browser_name = $browser['browser'];
$version = $browser['version'];
mysql_query("
INSERT INTO table_tester(`trackerID`,`id`, `timestamp`, `useragent_browser`,`useragent_OS`,`useragent`)
SELECT `trackerID`, `id`, `timestamp`, `useragent_browser`, `useragent_OS`,'".$col3["ua"]."'
FROM $table")
or die(mysql_error());
}
Its because your code is for only one row if you want to check all rows then put your content inside while loop for id and useragent like:
$myarray = mysql_query("SELECT * FROM table_105");
while($row = mysql_fetch_array($myarray)){
$table = 'tracktable_105';
$update = mysql_query("SELECT id as unp FROM $table");
while($col = mysql_fetch_assoc($update))
{
$col_id = ($col["unp"]);
$var1 = mysql_query("SELECT useragent as ua FROM paneltb WHERE id = $col_id");
while($col3 = mysql_fetch_assoc($var1))
{
$col_ua = $col3["ua"];
$browser = get_browser($col_ua, true);
$platform = $browser['platform'];
$device_name = $browser['device_name'];
$browser_name = $browser['browser'];
$version = $browser['version'];
mysql_query("
INSERT INTO table_tester(`trackerID`,`id`,`timestamp`,`useragent_browser`,`useragent_OS`,`useragent`) SELECT `trackerID`, `id`, `timestamp`, `useragent_browser`, `useragent_OS`,'".$col3["ua"]."' FROM $table") or die(mysql_error());
}
}
}