0

Hi I've been searching for this now for a few days and can't seem to get it right, hoping someone might be able to lend a hand. Here is the scenario:

techinfo table

repid fname lname region
1234  bob   smith  NY
4567  bob   sacamano toronto
3478  bob   hill   texas
9876  bob   underwood vancouver
7345  tom   tucker  halifax
2357  bill  shatner  LA

I am trying to find all of the bobs based on the input field looking for repid, first name, last name, etc...

basiacally if somone types bob into the form it should return all info for all the bobs.

I am totally stuck on this.

i have gotten to the point of determining if there is a bob record and can pull one, but i can't pull multiples.

here are some of the code snippets for example. any help is greatly apprecaited.

$MetaQuery="SELECT * FROM `techinfo` WHERE repid='$_POST[repid]' OR fname='$_POST[fname]'";
$MetaResults=mysql_query($MetaQuery, $DBconnect);
if(mysql_num_rows($MetaResults)>0)
{   
/*
quick check of array storage
*/
 echo "<br>we found results:".$row['repid']. $row['fname']. $row['lname'];
 }

1 Answer 1

2

1) mysql_ functions are being depericated use PDO

2) please learn about sql injection

3 mysql_query returns a resource that has to be looped though eg.

while($row = mysql_fetch_assoc($MetaResults) {
    echo "<br>we found results:".$row['repid']. $row['fname']. $row['lname'];
}
Sign up to request clarification or add additional context in comments.

1 Comment

thanks for the reply, just so i am clear from reading the spec on mysql_fetch_assoc, that query will get all rows containing "bob" for example and then store all the info for each colum/row? just wondering because with tinkering with your code example i couldn't get it to work. a little green on this stuff, but thanks for the help in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.