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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:53:27+00:00 2026-05-27T06:53:27+00:00

I’m working on a suggestions tool: When the user types a char into a

  • 0

I’m working on a suggestions tool: When the user types a char into a text field, the char gets sent off to a script (using AJAX) and is checked on in a SQL DB. If any entries in the DB match the users input, they get returned.

But I’m stuck on actually going through the users input string;

I need to check all characters one-by-one with each row in the DB.

So i was thinking:

1.) get the char length of the string and put it into $string_count

2.) define $count=0;

3.) do a while loop and make it stop when $count reaches over or equal to $string_count.

4.) inside that while loop: do another while loop and use condition: $det=mysql_fetch_array()

5.) then i could get the data (name) from row 1, and do a check to see if its first char matches the users input first char (which i don’t know how to do).

6.)If it contains the correct char in the correct position, add the ID to a string with a comma after ($possible.=$det['id'].",";)

7.) Add one to $count ($count++;) in the parent while loop.

7.) that loop will go on, on every row, but obviously changing char each time, until there are no more chars to check…

I just wrote all that up from the top of my head, and now I’m lost. I think its completely wrong and there is a much easier way to do it? but can you guys just tell me if im on the right track?

I need to know how to do a check on a certain char in a string. So for example:

$my_str="my name is nav nav";

now i want to get the forth char in that string (which is “n”).

any suggestions?

Thanks guys.

  • 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-27T06:53:27+00:00Added an answer on May 27, 2026 at 6:53 am
    $my_str="my name is nav nav";
    
    $charAt= $my_str{3};
    
    echo $charAt;
    
    //outputs n (strings are 0 indexed)
    

    EDIT: Also wait until the user has input at least three characters and just do a database query using LIKE everytime:

    SELECT * FROM example WHERE age LIKE '$userinput%' 
    

    http://www.htmlite.com/mysql011.php

    (optimizing this is another story)

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.