mysql - Merging two PHP scripts -


in 1st code have database query fetching information, example 'name' , display in table. works fine.

$query = ("select name ..."); $result = mysqli_query($con, $query);  while($row = mysqli_fetch_array($result, mysqli_assoc)) {     echo "<tr><td>";     echo $row['name'];     echo "</td></tr>\n"; } 

in 2nd code i'm getting information external website.

$ch = curl_init();  curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_followlocation, true); curl_setopt($ch, curlopt_useragent, "mozilla/4.0 (compatible; msie 5.01;windows nt 5.0)"); curl_setopt($ch, curlopt_url, "www.url.com/".$name); curl_setopt($ch, curlopt_header, 0);  $data = curl_exec($ch);  curl_close($ch);  $array = array(); $array = explode(',', $data); print_r($array); 

which displays in array

array (     [0] => 30     [1] => 24986 122     [2] => 40     [3] => 227449 .... 

currently both scripts work in separate php files , need define $name manually. however, join these , use name obtained code #1 database query in $name field in code #2. far gets random data array website , i'm little lost where/how input code. have not found proper way make work. help?

create main php file follows :

<?php  $query = ("select name ..."); $result = mysqli_query($con, $query);  while($row = mysqli_fetch_array($result, mysqli_assoc)) {      $ch = curl_init();      curl_setopt($ch, curlopt_returntransfer, true);     curl_setopt($ch, curlopt_followlocation, true);     curl_setopt($ch, curlopt_useragent, "mozilla/4.0 (compatible; msie 5.01;windows nt 5.0)");     curl_setopt($ch, curlopt_url, "www.url.com/".$row['name']);     curl_setopt($ch, curlopt_header, 0);      $data = curl_exec($ch);     curl_close($ch);      $array = array();     $array = explode(',', $data);      echo "<tr><td>";         echo $row['name'];     echo "</td></tr>\n";     echo "<tr><td>";         print_r($array); // display in table or want     echo "</td></tr>\n"; } 

like this, array depending on name of row fetched db, , same each results.

in example, append in table name, can it.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -