Jump to content

Archived

This topic is now archived and is closed to further replies.

cr-ispinternet

populating html via script

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.