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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:47:39+00:00 2026-06-14T18:47:39+00:00

I am working on creating a searchable database of all the students and associated

  • 0

I am working on creating a searchable database of all the students and associated information (for a larger project involving managing a iPad deployment). The database has 7 columns:

  • first_name
  • last_name
  • id_number
  • grade
  • grad_year
  • student_email
  • dob

What I need to do is return the entire row if the input matches any of the values in the row.

The PHP that I am working with is:

<?php 
$conn = mysql_connect ("localhost", "blmrvftl_ipdb", "ipad-db") or die ('I cannot connect to the database because: ' . mysql_error()); 
$selected = mysql_select_db ("blmrvftl_ipdb") 
or die ("Could not select database because: " . mysql_error()); 


// PHP Search Script 

$sql = "select * from phonebook, where first_name = '".$_GET['seek']."' or last_name = '". $_GET['seek'] ."' or id_number = '". $_GET['seek'] ."'";
//$sql = "select * from student_database, where first_name = '".$_GET['seek']."' or last_name = '". $_GET['seek'] ."' or id_number = '". $_GET['seek'] ."' or grade = '". $_GET['seek'] ."' or grad_year = '". $_GET['seek'] ."' or student_email = '". $_GET['seek'] ."' or dob = '". $_GET['seek'] ."'"; 
// $sql = "select * from student_database, where first_name = '".$_POST['seek']."' or last_name = '". $_POST['seek'] ."' or id_number = '". $_POST['seek'] ."' or grade = '". $_POST['seek'] ."' or grad_year = '". $_POST['seek'] ."' or student_email = '". $_POST['seek'] ."' or dob = '". $_POST['seek'] ."'";
$result = mysql_query($sql,$conn)or die (mysql_error()); 


if (mysql_num_rows($result)==0){ 
echo "No Match Found"; 
}else{ 
while ($row = mysql_fetch_array($result)){ 
echo "Name: " .$row['first_name']." ".$row["last_name"]."<br>"; 
echo "Student ID: ".$row['id_number']."<br>"; 
// echo "Department: ".$row['department_name']."<br>"; 
// echo "Directorate: ".$row['directorate_name']."<br>"; 
//echo "Site: ".$row['site_name']."<br>"; 
//echo "Phone #: ".$row['pb_tel_ext']."<br>"; 
//echo "Email Address: ".$row['pb_email_address']."<br>"; 
echo "<br>"; 
echo "---------------------------------------------------------------------"."<br>"; 
} 
} 

mysql_close(); 
?>

What i am having issues with is that I can’t quite get the format right to get it to search all the columns. (the uncommented $sql line is a modified version of the original from the site i snatched this bit of code from.)
The error i get is:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where first_name = 'Elliott' or last_name = 'Elliott' or id_number = 'Elliott'' at line 1
  • 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-14T18:47:40+00:00Added an answer on June 14, 2026 at 6:47 pm

    You’ve got a rogue comma:

    select * from phonebook, where
    

    should be

    select * from phonebook where
    

    Other than that, should work – it looks OK on first glance.

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

Sidebar

Related Questions

I'm currently working on creating a new C# project that needs to interact with
I'm working on creating an HTML form that has an image in the background.
I am working on creating a model where I want all of the decimal
I am working on creating an image gallery which has thumbnails in different sizes.
I am currently working on creating the InitialCreate migration for a new database. I
I am working on creating a form which pulls data from a database, and
I am currently working on creating my own SMTP server for a project I
I'm working on creating an ASCII interface for a school project but I've run
I am working on creating an IronPython console similar to the IronPythonConsole project provided
I'm working on creating an app that will parse MSDN articles for meta-information such

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.