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

  • SEARCH
  • Home
  • 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 7742251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:13:53+00:00 2026-06-01T09:13:53+00:00

As I am new to this I would like your advice. So far I

  • 0

As I am new to this I would like your advice.
So far I have figured out two ways to populate form fields.
Say this is my html:

 <input id="test" name="test" type="text">  

As you see the id of each field matches the name.
When it’s time to populate the field from Sql i could either do:

PHP:

 <input id="test" name="test" type="text" value="<?php if(isset($SqlRequested['test'){echo $SqlRequested['test'];}">  

and similarily write all the fields of my form…
or add this in the head part
JQUERY:

<script>
 <?php  echo "$(document).ready(function(){";
        foreach ($SqlRequested as $id => $value){
                echo "$('#" . $id . "').val(\"" . $value . "\");"
                echo "};"
         echo "});"
 ?>
 </script>

besides the fact that the jQuery gives me some problems when the fields contain “enter/return” in them (which could be fixed by using .html or .text i guess)

Which one would you suggest, what are the drawbacks or pro’s of each method?
Any improovements to the code?
Is there some other way i am missing?
Any suggestions on easily fixing the little problem mentioned above?

Thanx in advance.

Edit: I just noticed the jQuery .populate, which im guessing is something like my second way, you just need to get your data in a format of {'id':'value',...}

  • 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-01T09:13:54+00:00Added an answer on June 1, 2026 at 9:13 am

    You should use PHP to render the page as someone without javascript wouldn’t get the values of your javascript version.

    PHP:
    Pros:
    All browsers will get what you want them to get.
    The output HTML is arguably more correct as it has the value that the user expects in it

    Cons:
    …Increased server load….by such a small amount that it should probably not even be a con

    JS:
    Pros:
    …

    Cons:
    Non JS enabled browsers won’t see the values you expect.

    Improvements:
    Write a function in PHP that will auto echo your value if it exists to cut down on duplicate typing. Something like:

    function echoValue($value) {
    global $SqlRequested;
        if(isset($value)){
            echo $value;
        }
    }
    

    Or if you wanted:

    function echoValue($value) {
    global $SqlRequested;
        if(isset($SqlRequested[$value])){
            echo $SqlRequested[$value];
        }
    }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new on this, and I would like to get some advice because I
First I would like to say that I am new to this site, never
I am new to this iPhone development.I would like to create a hybrid application
I am new to this field, and I would like to build a small
In PHP, to create a new object you would do something like this, $dog
I figured this would be simple, but being new to SSRS I'm not sure.
Im very new to all coding including jquery. I though this would have been
I found out this article I would like share with you. http://10rem.net/articles/net-naming-conventions-and-programming-standards---best-practices Naming convention
I'm new to jQuery. This would be no problem for me using XPath expressions,
i m new to this android application development i would be very much grateful

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.