Jump to content


Photo

populating html via script


  • Please log in to reply
2 replies to this topic

#1 cr-ispinternet

cr-ispinternet
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts

Posted 29 October 2006 - 02:47 PM

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 not
being populated can any one simplyfy this for me

any ideas?

Alan

#2 bqallover

bqallover
  • Members
  • PipPipPip
  • Advanced Member
  • 111 posts
  • LocationLeeds, UK

Posted 29 October 2006 - 03:32 PM

There are a few problems with that script. :)

1) The braces on the first while loop close a bit early again.
2) I think 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):

<?
	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);
?>

Not sure how much help that will be, I'm not exactly sure what it's meant to do.


#3 cr-ispinternet

cr-ispinternet
  • Members
  • PipPipPip
  • Advanced Member
  • 61 posts

Posted 29 October 2006 - 04:48 PM

Bqallover,

worked a treat that, just have to fingure out why my
java script now doesnt like html output when echoing from the database
in any case thats worked for me.

thank you so much

Alan




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users