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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T13:54:23+00:00 2026-05-28T13:54:23+00:00

I need help on my php, I don’t know how to do this but

  • 0

I need help on my php, I don’t know how to do this but what I want is the user to enter in a room number in a textbox and when the user submits the form, if the room number is not in the database then it should display a message stating room is invalid. Does anyone know if this is possible?

Below is relevant code:

Javascript code for validation:

         function validation() {

           var isDataValid = true;

        var roomTextO = document.getElementById("room"); 

    //this retrieves an element from the textbox where user enters in a room number

        var errRoomMsgO = document.getElementById("roomAlert");

     // this is where the alert message appears for validation



   if (roomTextO.value == ""){
          errRoomMsgO.innerHTML = "Please Enter in a Room Number";
          isDataValid = false;
        }else if (!trimmedRoomText.length){
          errRoomMsgO.innerHTML = "Please Enter in a Room Number"; 
          isDataValid = false;      
    }else{
                errRoomMsgO.innerHTML = ""; 
        }

        }

Below is relevant SQL where room numbers are stored in database:

<?php

    $roomresult = mysql_query( "SELECT Room FROM Room" );

?>

The name of the Table is “Room” and the Room numbers are stored under the field “Room”.

Below is the textbox where user enters in room number:

<p><strong>Room:</strong> <input type="text" id="room" name="roomChosen" /><br/><span id="roomAlert"></span></p>      <!-- Enter Room here-->   
  • 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-28T13:54:23+00:00Added an answer on May 28, 2026 at 1:54 pm

    Well you need to select by the room_id (or some other criteria[s] that will deliver a unique result) basic sql, really…

    $roomresult = mysql_query( "SELECT Room FROM Room WHERE Room_Id = " . (int) $_POST['roomChosen']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need help to use jConfirm with this existing code (php & Jquery &
I need help finishing this statement. It is frustrating that two of the PHP
i need help with disk_total_space function.. i have this on my code <?php $sql=select
I need help with a regex and I don't know how to go about
I need some help with re-working the logic on this php code. What I'd
I'm learning PHP and I don't know how to get this to even work.
I need help understanding how to implement this part of PHP code in Ruby.
I need some help, I have created this function and it works fine, but
I need some help tweaking this php code to print out a default value
I need help rewriting online.php to -> /users/online and profile.php?id=3426 to -> /users/3426 and

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.