What I want to do is store the value that is not empty into the database, my database connection is correct, the problem here is that when I store into the database only the Id increments and that is because the Id is set on auto-increment.
this is the code that I have:
include("connect.php");
mysql_select_db("scrapper",$conec);
for($i = $0; $i < $3; $i++){
foreach($html->find('span.lists',$i) as $e){
if(!empty($e->plaintext)){
$list[$i] = $e->plaintext;
echo $list[$i];
}
}
}
inside the foreach there are multiple blank strings "" and those are what im trying to avoid thats why I only want to store the plaintext when empty is negated, but I still keep getting nothing inside the database only two periods which are inside the '".$list[$i]."'. Also the echo above does work echo $list[$i]; It prints out what I want it to store in the database.
for($i = $0; $i < $3; $i++){
$res=mysql_query("insert into data (list) values('".$list[$i]."')");
}
here is more code:
$url = "http://www.seccionamarilla.com.mx/resultados/hospitales/distrito-federal/"; $html = file_get_html($url);
for($i = $0; $i < $5; $i++){
foreach($html->find('span.listado_destacado',$i) as $e){
if(!empty($e->plaintext)){
$list = $e->plaintext;
echo $list;
}
}
foreach($html->find('span.street-address',$i) as $e){
if(!empty($e->plaintext)){
$addr = $e->plaintext;
echo $addr;
}
}
echo '<br>';
}//end for
for($i = $0; $i < $5; $i++){
$res=mysql_query("insert into data (list,addr) values('{$list}','{$addr}')");
}
This Is what I get after I run the program:
ANESTESIA Y CONTROL DEL DOLOR MEDICOS ASOCIADOS SC RIO CHURUBUSCO 601 421, XOCO, BENITO JUAREZ, C.P 03330, DF
CENTRO HOSPITALARIO SANATORIO DURANGO DURANGO 296, ROMA, CUAUHTEMOC, C.P 06700, DF
CLISEM NICOLAS SAN JUAN 351, DEL VALLE CENTRO, BENITO JUAREZ, C.P 03100, DF
HOSPITAL MEDICA SAN LUIS SAN LUIS POTOSI 122, ROMA NORTE, CUAUHTEMOC, C.P 06700, DF
MEDICA PALMAS LAS PALMAS 10, GRANJAS CABRERA, TLAHUAC, C.P 13230, DF
$e->plaintextplesae?