Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8891031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:38:09+00:00 2026-06-14T22:38:09+00:00

I had a PHP page where I was echoing out all the HTML. After

  • 0

I had a PHP page where I was echoing out all the HTML. After being advised that is poor practice, and that I should write out the HTML and only switch to PHP when I need it, I am trying to rewrite my form to adhere to that.

I’ve tried the following, however the $row array which contains the results of my SQL query are not being called correctly,

<?php while($row = $sth->fetch()){ ?>
<p>
<input type = "hidden" name ="id" value="<?php $row["id"] ?>"/>';
<p>
<input type = "text" name ="firstName" size ="30" value=" <?php $row["firstName"]?>"/>';</p>
<p>
<input type = "text" name ="lastName" size ="30" value="<?php $row["lastName"]?>"/>';
</p>";
<input type="submit" value="Update" />';
<?php } ?>

From my understanding as long as the start and end brackets are still in the right order, the above code should work, however it does not.

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:38:11+00:00Added an answer on June 14, 2026 at 10:38 pm
    <?php while($row = $sth->fetch()){ ?>
    <p>
    <input type = "hidden" name ="id" value="<?php echo $row["id"]; ?>"/>';
    <p>
    <input type = "text" name ="firstName" size ="30" value=" <?php echo $row["firstName"]; ?>"/>';</p>
    <p>
    <input type = "text" name ="lastName" size ="30" value="<?php echo $row["lastName"]; ?>"/>';
    </p>";
    <input type="submit" value="Update" />';
    <?php } ?>
    

    You forgot to put echo, without echo it won’t print anything.

    You have another option, which is:

    <?php while($row = $sth->fetch()){
    echo<<<HTML
    <p>
    <input type = "hidden" name ="id" value="{$row['id']}"/>';
    <p>
    <input type = "text" name ="firstName" size ="30" value=" {$row['firstName']}"/>';</p>
    <p>
    <input type = "text" name ="lastName" size ="30" value="{$row['lastName']}"/>';
    </p>";
    <input type="submit" value="Update" />';
    HTML;
    } ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update, Solved: After all this I found out that I was calling an old
i had an html page that run some jQuery scripts and that works ok.
I had a contact form that submitted to a php page with this content:
I had a PHP processing script for an HTML form that had been working
Using PHP / MySQL all encoded up as UTF, we have recently had to
I am trying to write a program in PHP which I had already written
I got a PHP web service that had been running great for a long
i had use Ajax using jquery. Now i had one page and in that
I'm working on a site in php. Originally I had a lot of html
Let's assume that we have a PHP class Page , which generates PHP Page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.