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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:13:07+00:00 2026-05-26T09:13:07+00:00

I have a MySQL table with a number of columns, including one called ‘Name’.

  • 0

I have a MySQL table with a number of columns, including one called ‘Name’.

I would like to design a form for a webpage which consists of two textboxes, A and B. In textbox A the user would be required to enter their name, and in textbox B some other information.

I would like the PHP script to check if the Name in Textbox A matches a value already in the Name column in the MySQL table, and if it does, add the value in Textbox B to another column in this table. If the name is not found, I would like the script to return an error, along the lines of “Your booking was not found on our database”.

Is it possible to do this using PHP/MySQL and if it is, how would I go about this?

CURRENT CODE

$row_count = count($_POST['name']);

mysql_select_db($database, $connection);

if ($row_count > 0) {

$values = array();

 for($i = 0; $i < $row_count; $i++) {
     // variable sanitation...
     $name = mysql_real_escape_string(ucwords($_POST['name'][$i]));
     $workshop = mysql_real_escape_string($_POST['workshop'][$i]);

     $query = "SELECT * FROM conference WHERE Name = '$name' ";
     $result = mysql_query($query);

     if ($result) {
     $rowcount = mysql_num_rows($result);

     if ($rowcount == 0) {echo "no bookings found"; }
     else {
     $row = mysql_fetch_row($result);
     $sql = "UPDATE conference SET Workshop = '$workshop' WHERE Name = '$name'";
     mysql_query($sql);
     }

     }
}

}
  • 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-26T09:13:07+00:00Added an answer on May 26, 2026 at 9:13 am

    This should get you started.

    //Get the value from the textbox
    $name = mysql_real_escape_string($_POST['name']);
    //Select all rows with the name
    $query = "SELECT other_info FROM table1 WHERE name = '$name' ";
    $result = mysql_query($query);
    if ($result) {
      $rowcount = mysql_num_rows($result);
      //No rows found
      if ($rowcount == 0) {echo "no bookings found"; }
      else {
        //process the data.
        $row = mysql_fetch_row($result);
        $other_info = $row['other_info'];
        echo "other_info = ".hmtlentities($other_info);
    

    See here: http://php.net/manual/en/book.mysql.php

    Comments on the code

    $row_count = count($_POST['name']);
    if ($row_count > 0) {
    
      mysql_select_db($database, $connection);
      //$values = array(); 
      $name = array();
      $workshop = array()
      $replace = array()
    
      for($i = 0; $i < $row_count; $i++) {
        // variable sanitation...
        $name[i] = mysql_real_escape_string(ucwords($_POST['name'][$i]));
        $workshop[i] = mysql_real_escape_string($_POST['workshop'][$i]);
        //if you use option 2
        $replace[i] = "('".$name[i]."','".$workshop[i]."')";
      }
      $names = "'".implode("','",$name)."'";
      $query = "SELECT 1 FROM conference WHERE Name IN $names "; 
      $result = mysql_query($query);
    
      if ($result) {
        $rowcount = mysql_num_rows($result);
    
        if ($rowcount == 0) {
          echo "<HTMLCODE HERE>"."no bookings found"."<MORE HTML>"; 
        //OPTION 1
        } else {
          for($i = 0; $i < $row_count; $i++) {
            //$row = mysql_fetch_row($result);  
            $sql = "UPDATE conference SET Workshop = '$workshop[i]' 
                    WHERE Name LIKE '$name[i]'";
            mysql_query($sql);
          }
        }
        //OPTION2
        } else {
          $replacement = implode(",",$replace);
          $sql = "REPLACE INTO conference (names, workshop) VALUES $replacement "
          mysql_query($sql);
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have such mysql db table: id name surname number 1 emil asadi 26
I have a MySQL table and would like to return the rows based on
I have a mysql table structure like that: id int primary key name varchar
What's the max number of columns a mysql table can have?
I have a MySQL table with columns id, name and active. I need to
I have a (mysql) database table with the following columns: NAME | String (Unique)
I have a mysql table , which holds data like this. Name |how_out |runs
Okay, so let's say I have a mysql database table with two columns, one
I have a mysql database with table 'product' containing columns 'product_id', 'name', 'price' table
Ok, I have a single MySQL table with the name 'test' and 3 columns.

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.