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 8374643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:58:01+00:00 2026-06-09T14:58:01+00:00

I am using PHP to get fields from my database I am using the

  • 0

I am using PHP to get fields from my database I am using the following code:

$result = mysql_query("SELECT * FROM product_form WHERE id=1");
while($row = mysql_fetch_array($result))
   {
   $ProductName = $row['ProductName'];
   $ProductName1 = $row['ProductName1'];
   $ProductName2 = $row['ProductName2'];
   $ProductName3 = $row['ProductName3'];
   $ProductName4 = $row['ProductName4'];
   $ProductName5 = $row['ProductName5'];
   }

I then am displaying the filed on the page like this:

<? echo("<input type='text' name = 'product_name' size='29' value='$ProductName'/>");?>
<? echo("<input type='text' name = 'product_name1' size='29' value='$ProductName1'/>");?>
<? echo("<input type='text' name = 'product_name2' size='29' value='$ProductName2'/>");?>
<? echo("<input type='text' name = 'product_name3' size='29' value='$ProductName3'/>");?>
<? echo("<input type='text' name = 'product_name4' size='29' value='$ProductName4'/>");?>
<? echo("<input type='text' name = 'product_name5' size='29' value='$ProductName5'/>");?>

The problem I am facing is that ProductName & ProductName1 are displaying correctly but ProductName2, ProductName3, ProductName4, ProductName5 is only showing the first word from the database.

However when I view it in phpMyAdmin it is showing more then one word for the field.

I seem to be able to echo and display it on the page but can’t echo/display the full field in a text box, it seems to drop everything after a ‘space’ when displaying it in a text box but it does work when just displaying it on a page not in a text box.

Anyone know where I am going 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-09T14:58:02+00:00Added an answer on June 9, 2026 at 2:58 pm

    Create new test.php and paste following code into it and run.

     $con = mysql_connect("localhost","root","");   //check mysql login credentials
     mysql_select_db("test",$con);   // change database name here
     $query = "SELECT * from product_form WHERE id = 1;";
     $rs = mysql_query($query);
     $row = mysql_fetch_array($rs);
     print_r($row);     // as you are using one record. no need of while loop
    
     echo "<Input type='text' name = 'product_name' value=".$row[ProductName].">";
     echo "<Input type='text' name = 'product_name1' value=".$row[ProductName1].">";
     echo "<Input type='text' name = 'product_name2' value=".$row[ProductName2].">";
     echo "<Input type='text' name = 'product_name3' value=".$row[ProductName3].">";
     echo "<Input type='text' name = 'product_name4' value=".$row[ProductName4].">";
     echo "<Input type='text' name = 'product_name5' value=".$row[ProductName5].">";
    

    Now see what comes as result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently using the following PHP code: // Get all subordinates $subords = array();
Using jQuery I get JSON object that extracts one row from database. That row
The PHP code won't delete item from database using $noteid. If I put a
using a drop-down list that's populated from database fields, i need to select an
Im using this PHP to get a list of Title's from an RSS feed:
Using php I am trying to get some data from a .csv file which
I'm new to PHP. I'm using the following code to generate an excel sheet
I am using the following code. <?php //DB CONNECTION $ROWS = id,firstname,lastname; // explode
I have an issue going on here. I am using PHP to get values
Possible Duplicate: PHP get both array value and array key I am using Codeigniters'

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.