phoenixx Posted August 4, 2008 Share Posted August 4, 2008 I've done this before but don't have the sample of how I did it. Actually I think I lucked out last time. I'm scraping a form from another one of my sites and trying to add a dynamic value to each of the results so that I can add the value to my database, but can't get the variable assignment for the output. Here's my code... I would really appreciate any help you may have. <?php $data = @file_get_contents("https://XXX.com/XXX/XX/XXX/XXX/XXX/[email protected]&inputPassword=XXX", "r"); ; //preg_match_all('/<input.*?name="([^"]*)".*?value="([^"]*)"/is',$data,$out); //preg_match_all('/<input.*?name="([^"]*)".*?value="([^"]*)"/is',$data,$out); //$d = array_combine($out[1], $out[2]); //print_r($d); preg_match_all('/<input.*?name="([^"]*)".*?value="([^"]*)"/is',$data,$out); $d = array_combine($out[1], $out[2]); //$insert_into = array(); $cl=("Fieldname"); foreach($d as $k=>$v){ echo .$cl[11] . " = " . $k . "=" . $v . "<br>"; } \mysql_connect("localhost", "XXX", "XXX") or die(mysql_error()) ; mysql_select_db("XXX") or die(mysql_error()) ; mysql_query("INSERT INTO XXX(ttb_dynamicid,ttb_postingkey,ttb_test,ttb_postingtitle,ttb_postingprice,ttb_postinglocation,ttb_postingdescription,ttb_imagefile1,ttb_imagefile2,ttb_imagefile3,ttb_imagefile4,ttb_emailmask,ttb_timestamp,ttb_extra1) VALUES ('','$cl1','$cl2','$cl3','$cl4','$cl5','$cl5','$cl6','$cl7','$cl8','$cl9','$cl10','$cl11','$cl_timestamp','')") or die(mysql_error()); ?> Link to comment https://forums.phpfreaks.com/topic/118122-dynamic-variables-multidimensional-array/ Share on other sites More sharing options...
lemmin Posted August 4, 2008 Share Posted August 4, 2008 Could you be more specific as to what you are trying to do? Link to comment https://forums.phpfreaks.com/topic/118122-dynamic-variables-multidimensional-array/#findComment-607746 Share on other sites More sharing options...
phoenixx Posted August 4, 2008 Author Share Posted August 4, 2008 I need the variable $cl to auto increment. The $cl value should be able to output the variable $fieldname1, $fieldname2, etc.. for each change in the foreach($d as $k=>$v){ the information scraped from my sister site uses dynamic field names instead of field values... so to insert them into the database in the correct order I need to assign the name a $fieldname1=('$scrapedvalue'); $fieldname2=('$scrapedvalue'); etc... but each loop makes the scraped value different. Link to comment https://forums.phpfreaks.com/topic/118122-dynamic-variables-multidimensional-array/#findComment-607752 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.