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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:20:30+00:00 2026-06-14T23:20:30+00:00

<?php require_once(‘../lankain.php’); if(isset($_POST[‘queryString’])) { $queryString = $dbc->real_escape_string($_POST[‘queryString’]); if(strlen($queryString) >0) { //$query = $dbc->query(SELECT subjects

  • 0
<?php

require_once('../lankain.php');

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

    $queryString = $dbc->real_escape_string($_POST['queryString']);

    if(strlen($queryString) >0) {
        //$query = $dbc->query("SELECT subjects FROM subject WHERE subjects LIKE '$queryString%' LIMIT 10");
        $q = "SELECT keyword, col 
                FROM (
                    SELECT tutor_name AS keyword, 'Tutors' col FROM tutors
                    UNION
                    SELECT subjects AS keyword, 'Subject' col FROM subject
                    UNION
                    SELECT city_name AS keyword, 'City' col FROM city
                    UNION
                    SELECT institute_name AS keyword, 'Institute' col FROM institutes
                ) s
              WHERE keyword LIKE '%$queryString%' 
              LIMIT 10";

        $r = mysqli_query ( $dbc, $q);

        if($q) {
        while ($row = mysqli_fetch_array($r, MYSQL_ASSOC)) {

            $col = $row['col'];


        }
        } else {
            echo 'ERROR: There was a problem with the query.';
        }
    } else {

    }
} else {
    echo 'There should be no direct access to this script!';
}

?>

My query only select subjects, tutor names, institutes and city not selecting category names. Now I need to add category name according to the result set..

can I know is it possible to do with php?

  • 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-14T23:20:31+00:00Added an answer on June 14, 2026 at 11:20 pm

    Try this:

    SELECT col, keyword
    FROM (SELECT tname AS keyword, 'Tutors' col FROM t
          UNION
          SELECT sname AS keyword, 'Subjects' col FROM sub
          UNION
          SELECT cname AS keyword, 'City' col FROM c
          UNION
          SELECT iname AS keyword, 'Institutes' col FROM i
        ) AS s
    WHERE keyword LIKE '%$queryString%' 
    LIMIT 10
    

    How do you want category mapped with result set?

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

Sidebar

Related Questions

from my logout.php : <?php require_once(includes/session.php); ?> <?php require_once(includes/functions.php); ?> <?php if ( isset(
<?php require_once 'swift-mailer/lib/swift_required.php'; if (isset($_POST['submit'])) { //File upload // Where the file is going
<?php require_once('./includes/connection.php'); ?> <?php require_once('./includes/sql_func.php');?> <?php if(isset($_POST['submit'])) { $isValid = verify_account($_POST['username'],$_POST['password']); if($isValid){ session_name($_POST['username']); session_start();
Here is my code <?php require_once 'connect.php'; $sql = SELECT * FROM `db-pages`; $result
I'm trying to retrieve the response of this script: <?php require_once(db_connect.php); $get = mysql_query(SELECT
Html Form Submitted from <?php //////////////////////////////////////////////////////////////////////////////////// ###### Require Database ###### //////////////////////// require_once('src/cfg/dbi.php'); //////////////////////////////////////////////////////////////////////////////////// ######
I am running this php script from an ajax call: <?php require_once('myConnectDB.inc.php'); //add beer
<?php require_once Mail.php; $from = <niko@gmail.com>; $to = <niko@hotmail.com>; $subject = Hi!; $body =
I have some files: core.php : require_once 'logger.php'; require_once 'smth_else.php'; $Logger = new Logger();
index.php <?php require_once('fr.php'); header('Location:'.abspath().directory()); ?> fr.php <?php require_once('functions.php'); ?> functions.php function abspath() { return

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.