passing php variable to html - is it possible?

In the code listed below, I want to be able to pass the value from the varibles in the sql select statement to the html page below. (Note: the only one I'm trying is the $company variable, I'll do the rest when I get that to work.) The problem is that no matter what I use in the value clause in the html, it doesn't evaluate the variable to the value. Can anyone help me out? I'm new to this, so I'm pretty sure I'm doing something silly to cause this.

$link = mysql_connect('', 'xxxxxx', 'pw','db');
if (!$link) {
printf("Connect failed: %s
", mysql_error());
} else {
// select the database
$db_selected = mysql_select_db('testdb', $link);
if (!$db_selected) {
die ('Select db failed: testdb: ' . mysql_error());
// Perform Query
$query ="select * from leadsTable";
$result = mysql_query($query);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "
$message .= 'Whole query: ' . $query;
} else {
while ($newArray = mysql_fetch_array($result, MYSQL_ASSOC)) {
$id = $newArray['id'];
[b][red]$company = $newArray['company_name'];[/red][/b]
$contact = $newArray['contact'];
$phone = $newArray['phone'];
$fax = $newArray['fax'];
$street = $newArray['street'];
$city = $newArray['city'];
$state = $newArray['state'];
$zip = $newArray['zip'];
$job_type = $newArray['job_type'];
$license_class = $newArray['license_class'];
$experience = $newArray['experience'];
$date_found = $newArray['date_found'];
$date_of_contact = $newArray['date_of_contact'];
$notes = $newArray['notes'];
echo "ID is ".$id.
"<br/>Company: ".$company.
Contact: &nbsp ".$contact.
Phone: &nbsp &nbsp ".$phone.
Fax: &nbsp &nbsp &nbsp &nbsp ".$fax.
Street: &nbsp &nbsp ".$street.
City: &nbsp &nbsp &nbsp &nbsp ".$city.
State: &nbsp &nbsp &nbsp ".$state.
Zip: &nbsp &nbsp &nbsp &nbsp ".$zip.
Job Type: &nbsp ".$job_type.
License: $nbsp ".$license_class.
Experience: ".$experience.
Date Found: ".$date_found.
Date of Contact: ".$date_of_contact.
Notes: $nbsp ".$notes.
echo "Rows returned: ". $rows;

Update Leads Table

This php echo statement displays the value I'm looking for!
<? echo "company $company<br>"; ?>
Update Lead
Company : Date Found :



  • You are forgetting to tell the parser that the Value is a PHP variable...


  • You are forgetting to tell the parser that u have switched to PHP ...


  • Thank you very much! I'm new to this, so I'll make sure to remember this in the future!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion