passing php variable to html - is it possible? - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

passing php variable to html - is it possible?

peterv6peterv6 Posts: 18Member
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 :



  • tradmtradm Posts: 49Member
    You are forgetting to tell the parser that the Value is a PHP variable...


  • tradmtradm Posts: 49Member
    You are forgetting to tell the parser that u have switched to PHP ...


  • peterv6peterv6 Posts: 18Member
    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.