Jump to content

populating html via script


cr-ispinternet

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.