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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:14:34+00:00 2026-06-09T19:14:34+00:00

There might be an easy answer to this, but I can’t for the life

  • 0

There might be an easy answer to this, but I can’t for the life of me get this to work.

I’m using PHP and MySQL and have something like this set up:

    $studentname = mysql_real_escape_string($_POST['sname']);
        $studentnumber = mysql_real_escape_string($_POST['snumber']);
        $course = mysql_real_escape_string($_POST['courseselect']);

        $bike3 = mysql_query("SELECT stoodnumber FROM bikes505 WHERE stoodname='" . $studentname . "'");
        $bikestoods = mysql_fetch_array($bike3);

    while($row = mysql_fetch_array($stoodlistq))
            {
                $stoodentname = $row['stoodname'];
                $stoodentnumber = $row['stoodnumber'];
                //$coursename = $row2['coursename'];
                //$coursecode = $row2['coursecode'];


                if($studentname == $stoodentname && $studentnumber == $stoodentnumber){
                    //$success = 1;
                        //$success = "yupp";
                        //echo "SUCCESS, WE CAN REGISTER YOOOU!";
                        echo "<br>";

                        //echo "INSERT INTO " . $course . "";
                        switch($course){
                            case "Biking Safely":
                                if($studentnumber = $bikestoods[0] or $bikestoods[1]){
                                    echo "Sorry, this student has already registered";
                                } else if($bikecurrent < $bikemax){
                                    mysql_query("INSERT INTO bikes505 VALUES ('" . $stoodentname . "','" . $stoodentnumber . "')");
                                    echo "Yay, successfully registered " . $stoodentname . " - " . $stoodentnumber . " for " . $course;
                                    echo "<br>";
                                } else{
                                    echo "Sorry, class is full!";
                                }
                                break;

…and so on. The only problem that I’m having is that if I have two students with the same name, the second in the list will echo that the information is not correct.

For example, the MySQL table has ‘stoodname’ and ‘stoodnumber’, and if ‘Jimmy St.James’,’1010′ and ‘Jimmy St.James’,’1090′ are both records in the table it will only let me enroll Jimmy 1010 in the course and not Jimmy 1090.

Am I just way off with how I’m validating? Or am I missing something really obvious? At first I assumed it was just because I was only using the first item in the array $bikestoods[0] so I changed it to $bikestoods[0] or $bikestoods[1] and it still doesn’t work.

  • 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-09T19:14:35+00:00Added an answer on June 9, 2026 at 7:14 pm

    Per a comment, you have $stoodlistq defined as:

    $stoodlistq = mysql_query("SELECT * FROM stoodinfo");
    

    Later, you use the following block of code:

    $studentname = mysql_real_escape_string($_POST['sname']);
    $studentnumber = mysql_real_escape_string($_POST['snumber']);
    ...
    while($row = mysql_fetch_array($stoodlistq)) {
        ...
        if($studentname == $stoodentname && $studentnumber == $stoodentnumber){
    

    The while() loop in this code iterates over every record, however, the if-statement checks against the POST variables. The POST variables make up a single combination for “one student” – therefore, you’ll only ever get a single student that can be enrolled.

    To fix the issue, you’ll either need to update your form that submits the “student name”/”student number” to accept multiple inputs – or update the if-statement to only check against the student’s name (which could lead to a more undesired situation).

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

Sidebar

Related Questions

There is probably an easy to answer to this, but I can't even figure
There might be an easy solution here, but it seems to have me tripped
I have a general question that may be easy to answer, but it might
This might be a silly question, but as I can't find an answer, I
This one might be a bit basic and easy to answer, but I've been
Im sure there is an easy answer for this one, but I've been looking
I know this might be a silly question, with an easy answer, but after
I am hoping that there might be an easy way to do this, I
There might be a really simple solution to this question, but i just don't
There might be similar questions but I still have some parts that I couldn't

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.