mysql searching

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
plodos
Forum Newbie
Posts: 11
Joined: Wed Jan 30, 2008 12:16 pm

mysql searching

Post by plodos »

my dbase...

Code: Select all

CREATE TABLE `user` (
`user_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`first_name` VARCHAR( 40 ) NOT NULL ,
`last_name` VARCHAR( 40 ) NOT NULL ,
`email` VARCHAR( 128 ) NOT NULL ,
`country` VARCHAR( 128 ) NOT NULL ,
`university_dep` VARCHAR( 250 ) NOT NULL ,
`university` VARCHAR( 250 ) NOT NULL ,
`phone` VARCHAR( 30 ) NOT NULL
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
 
CREATE TABLE `editor` (
`editor_id` SMALLINT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`editor` TEXT
) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
 
CREATE TABLE `user_editor` (
`user_id` INT NOT NULL ,
`editor_id` SMALLINT NOT NULL ,
PRIMARY KEY ( `user_id` , `editor_id` )
) ENGINE = MYISAM ;
 
query ¿

Code: Select all

 
$data = mysql_query("SELECT * FROM editor WHERE editor LIKE '%ijas%' "); 
while($info=mysql_fetch_array($data) )
{
Print "<tr>";
Print "<th>Committee:</th> <td>{$info['editor']}</td> ";
Print "<th>Name:</th> <td>{$info['first_name']}</td> ";
Print "<th>Surname:</th> <td>{$info['last_name']}</td> ";
Print "<th>Country:</th> <td>{$info['country']} </td>";
Print "<th>University:</th> <td>{$info['university']} </td>";
Print "<th>University Department:</th> <td>{$info['university_dep']} </td>";
Print"</tr>";
}
 
My problem is that, i have editor table and editor field... each of the editor field has value(s)...
like that http://img264.imageshack.us/my.php?imag ... gdfpw9.jpg

and i want to search "ijas" word, if the user(s) has ijas word, php code will show the name surname universitry..

but i didnt write the query pls help :S
Post Reply