cr-ispinternet Posted October 29, 2006 Share Posted October 29, 2006 something im stuck with...does any one know how i can solve this, maybe im just not thinking about it#!/usr/bin/php -q<? mysql_connect("localhost","username","password"); $query = "SELECT * from locations 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_job_number = "$row->job_number"; $display_job_date = "$row->job_date"; } $query2 = "SELECT * from geolocations where postcode= '$display_postcode_district'"; $result2 = mysql_db_query('blucat',$query2); while($row = mysql_fetch_object($result2)) {echo <<<END$name= '<font face="Tahoma" style="font-size: 8pt">$row->company_name<br>$row->contact_name$row->town<br>$row->postcode_district$row->postcode_sector<br>T: $row->contact_number<$END; /* Generates Insert Statement */ $query3 = "update locations set name='$name', lat='$row->latitude', lng='$row->longitude' where company_name='$display_company_name' and job_number='$display_job$ mysql_db_query('blucat',$query3); /* Generates update converted statement */ $query4 = "UPDATE locations set converted='yes'"; $result4 = mysql_db_query('blucat',$query4); }?>im trying to get that html in to a text field in the database but the values are notbeing populated can any one simplyfy this for meany ideas?Alan Link to comment https://forums.phpfreaks.com/topic/25486-populating-html-via-script/ Share on other sites More sharing options...
bqallover Posted October 29, 2006 Share Posted October 29, 2006 There are a few problems with that script. :)1) The braces on the first while loop close a bit early again.2) I [i]think[/i] you've got the syntax of the HEREDOC assignment a bit wrong, again if I read you right. To use HEREDOC when assigning to a variable you do something like... $variable = <<<END .... etc.3) The SQL needs a bit of tidying up ;)Try this (or something very like it):[code]<? mysql_connect("localhost","username","password"); $query = "SELECT * from locations 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_job_number = "$row->job_number"; $display_job_date = "$row->job_date"; $query2 = "SELECT * from geolocations where postcode= '$display_postcode_district'"; $result2 = mysql_db_query('blucat',$query2); while($row = mysql_fetch_object($result2)) {$name = <<<END<font face="Tahoma" style="font-size: 8pt">$row->company_name<br />$row->contact_name<br />$row->town<br />$row->postcode_district $row->postcode_sector<br />T: $row->contact_number</font>END; /* Generates Insert Statement */ $query3 = "update locations set name='$name', lat='$row->latitude', lng='$row->longitude' where company_name='$display_company_name' and job_number='$display_job_number'"; mysql_db_query('blucat',$query3); } } /* Generates update converted statement */ $query4 = "UPDATE locations set converted='yes'"; $result4 = mysql_db_query('blucat',$query4);?>[/code]Not sure how much help that will be, I'm not exactly sure what it's meant to do. Link to comment https://forums.phpfreaks.com/topic/25486-populating-html-via-script/#findComment-116287 Share on other sites More sharing options...
cr-ispinternet Posted October 29, 2006 Author Share Posted October 29, 2006 Bqallover,worked a treat that, just have to fingure out why myjava script now doesnt like html output when echoing from the databasein any case thats worked for me.thank you so muchAlan Link to comment https://forums.phpfreaks.com/topic/25486-populating-html-via-script/#findComment-116319 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.