cr-ispinternet Posted October 29, 2006 Share Posted October 29, 2006 Hi guys,im doing some last minute work on a comapny portalby adding gogle maps in there, the engineer can then lookup his jobs for the day and also view a map of the locationwhere the job is at ( accurate to 100M )problem is im having a nightmare with some code in orderto get the geo locations so i can feen them to the google maps page.i have a database called pda_jobs in here is all the info i need for the jobfrom there i need to copy 5 or 6 fields over to another table called locationsthis table basically if for a view of the uk with all jobs active for the dayand where they are mapped by the google api ballon.what im struggling with is when ever i execute the script ive writtenit does just one line and thats it, i think personally im being stupidand have missed something.heres the codethe pda_jobs database has a field called converted so each time thescript is run it does not have to process each one again.#!/usr/bin/php -q<? mysql_connect("localhost","databse","password"); $query = "SELECT * from pda_jobs where converted= 'no'"; $result = mysql_db_query('blucat',$query); while($row = mysql_fetch_object($result)) { $display_company_name = "$row->company_name"; $display_postcode_district = "$row->postcode_district"; $display_postcode_sector = "$row->postcode_sector"; $display_job_number = "$row->job_number"; $display_job_date = "$row->job_date"; } /* Generates Insert Statement */ $query1 = "insert into locations values( '', '', '', '', '$display_company_name', '$display_postcode_district', '$display_postcode_sector', '$display_job_number', '$display_job_date', 'no')"; $result1 = mysql_db_query('blucat',$query1); $query3 = "UPDATE pda_jobs set converted='yes'"; $result3 = mysql_db_query('blucat',$query3);?>can any one tell me how i can re write the code so it processes allentries as its reading one line then stopping.say there are 4 entries for jobs today, when the script is ran from croni want it to process each of those 4 lines and insert the data intothe locations databse.any help would be much appreciatedAlan Link to comment https://forums.phpfreaks.com/topic/25478-command-line-php-script/ Share on other sites More sharing options...
bqallover Posted October 29, 2006 Share Posted October 29, 2006 I think your problem lies in the position of the closing brace of the while loop. It should be lower - if I understand you correctly - like this...[code]<? mysql_connect("localhost","databse","password"); $query = "SELECT * from pda_jobs where converted= 'no'"; $result = mysql_db_query('blucat',$query); while($row = mysql_fetch_object($result)) { $display_company_name = "$row->company_name"; $display_postcode_district = "$row->postcode_district"; $display_postcode_sector = "$row->postcode_sector"; $display_job_number = "$row->job_number"; $display_job_date = "$row->job_date"; /* Generates Insert Statement */ $query1 = "insert into locations values( '', '', '', '', '$display_company_name', '$display_postcode_district', '$display_postcode_sector', '$display_job_number', '$display_job_date', 'no')"; $result1 = mysql_db_query('blucat',$query1); } $query3 = "UPDATE pda_jobs set converted='yes'"; $result3 = mysql_db_query('blucat',$query3);?>[/code]Hope that's of some use. :) Link to comment https://forums.phpfreaks.com/topic/25478-command-line-php-script/#findComment-116279 Share on other sites More sharing options...
cr-ispinternet Posted October 29, 2006 Author Share Posted October 29, 2006 ha ah hamakes me laugh you know php, you get high blood preasuresweats, and anger all from....wait for it...a }bloody thingswell thats me sortedhttp://engineer.blucat.co.uk/gmaps/index.htmlthats what ive been trying to do :-) Link to comment https://forums.phpfreaks.com/topic/25478-command-line-php-script/#findComment-116326 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.