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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:31:24+00:00 2026-05-30T22:31:24+00:00

I have code to retrieve data from a database into a form but it

  • 0

enter image description here

I have code to retrieve data from a database into a form but it doesnt seem to be working. The code below is my attempt but it doesnt work. Currently, when I click the submit button ‘retrieve rose’ it does nothing…

//if we have no errors, do the SQL
if (!$errors) {   

$latin_name = $_POST['latin_name'];

$stmt = $conn2->prepare("SELECT common_name, variety_name, colour, season_of_interest, hardiness, situation, soil_type,
price, stock_level, fragrance, ultimate_height FROM rosename WHERE latin_name = ?");

$stmt->bind_param('ssssssssdiss', $latin_name);

if ($result = $stmt->get_result()) {
    /* fetch associative array */
    echo "<form><input type='text' value='" . $row["common_name"] . "' name='latin_name' />";
    echo "<input type='text' value='" . $row["variety_name"] . "' name='soil_type' /></form>";
    } // i no I need to add more here...
    exit;
}

//put out the footer and then stop the rest of the script from running, so we don't display the rest of the form (this is after the form has been submitted)
require_once('footer.php');
exit;
}

//if we do have errors, show the error message
else {
  echo "<p>".$error_msg."</p>";
}}
?>

And here is my form:

<h1>Update Rose Item</h1>
  <ul class='register'>
      <li>
  <form action="updaterose.php" id="updaterose" method="post">
  <fieldset id="register">
        <label>Latin Name:<span class="small">Enter a Latin Name</span></label><input      name='latin_name' id='latin_name' type='text' value="<?=(isset($_POST['latin_name'])?  $_POST['latin_name']:"");?>" />
    <input type="submit" value="Retrieve Rose" name='retrieverose' /></br></br></br>
</form>

Code requested by mariogl

  //connect to database
$conn2 = DB2();

  require_once('header_admin.php');

  if (isset($_POST['updaterose'])) 
  {

//detect if we have errors or not
$errors = false;
$error_msg = "Error, please try again";
  • 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-05-30T22:31:25+00:00Added an answer on May 30, 2026 at 10:31 pm

    Your problem is the first condition, you’re asking for a variable named “updaterose”, that doesn’t exist. Try this:

      if (isset($_POST['retrieverose'])) 
      {
    
        //detect if we have errors or not
        $errors = false;
        $error_msg = "Error, please try again";
    
        //if we have no errors, do the SQL
        if (!$errors) {   
    
            $latin_name = $_POST['latin_name'];
    
            $stmt = $conn2->prepare("SELECT common_name, variety_name, colour, season_of_interest, hardiness, situation, soil_type, price, stock_level, fragrance, ultimate_height FROM rosename WHERE latin_name = ?");
    
            $stmt->bind_param('s', $latin_name);
            $stmt->execute();
    
            if ($result = $stmt->get_result()) {
                /* fetch associative array */
                echo "<form><input type='text' value='" . $result["common_name"] . "' name='common_name' />";
                echo "<input type='text' value='" . $result["variety_name"] . "' name='variety_name' /></form>";
                // i no I need to add more here..
                exit;
            }
    
            //put out the footer and then stop the rest of the script from running, so we don't display the rest of the form (this is after the form has been submitted)
            require_once('footer.php');
            exit;
        }
    
        //if we do have errors, show the error message
        else {
            echo "<p>".$error_msg."</p>";
        }}
    
    }
    

    Corrections on brackets and bind_param().

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

Sidebar

Related Questions

Basically i have php code which retrieves data from a database into a table,
I have some existing code that retrieves data from a database using ADO.NET that
i retrieve data from upc database and then want to insert the data into
I have the following code, which will retrieve a filename from a table and
I am trying to figure out how to retrieve data from a MySQL database
I have some data recieved from a simple HTML form like this: $newdata =
I have a web-app-database 3 tier server setup. Web requests data from app, and
I am using LINQ to retrieve data from the Database, the variable name relative
I have an HTML form that builds a drop-down from json data that is
I am trying to retrieve some data from a database using jQuery's $.getJSON method

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.