Welcome Guest, Not a member yet? Register   Sign In
search in two tables
#11

[eluser]anyamanggar[/eluser]
help me pleasee
#12

[eluser]skunkbad[/eluser]
First, why do you have identical table structure for two tables?

Code:
CREATE TABLE `berita` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(200) NOT NULL,
  `slug` varchar(200) NOT NULL,
  `tanggal` datetime default NULL,
  `img_path` text NOT NULL,
  `intro` text NOT NULL,
  `content` text NOT NULL,
  `kategori` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ;

CREATE TABLE `info` (
  `id` int(11) NOT NULL auto_increment,
  `title` varchar(200) NOT NULL,
  `slug` varchar(200) NOT NULL,
  `tanggal` varchar(100) NOT NULL,
  `img_path` text NOT NULL,
  `intro` text NOT NULL,
  `content` text NOT NULL,
  `kategori` varchar(100) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;

As you can see, these tables are identical. It is poor database design to have two tables that are identical, but if this is your only option, then how are the tables related? What is the link between the two tables? In most tables you have a unique ID as a "primary key" and you have a field in the second table that is a "foreign key". Use google for more information about relational database design if these terms are confusing you.

CodeIgniter is meant to be a way to organize code and it more or less creates shortcuts for you. This is the general purpose of a framework in my opinion. It would seem that you may not have enough experience using PHP and MySQL to use CodeIgniter effectively. If the CodeIgniter documentation on Active Record does not allow you to form your query easily, you can always resort to creating a query with raw sql:

Code:
$sql = '
     SELECT * FROM table1 LEFT JOIN table2 ON table1.field = table2.field2 WHERE table1.field3 = "something" LIMIT 1
';

$this->db->query( $sql );

If your problem is that you don't know enough about MySQL / SQL, then I suggest trying to learn more before proceeding with your application. Also, if your PHP skills are lacking, you may find that it is beneficial to learn more about PHP before using CodeIgniter. I'm working full time with PHP, and have been using it for over 6 years, and still have lots to learn. Don't be offended, but I just don't believe that CodeIgniter is for all experience levels.

I can't write your code for you, but willing to help if you have questions that I can answer. I'm in GMT -8:00, so it's time for me to go to sleep. Perhaps somebody else can help you if you have more questions.
#13

[eluser]anyamanggar[/eluser]
[quote author="skunkbad" date="1343025503"]

I can't write your code for you, but willing to help if you have questions that I can answer. I'm in GMT -8:00, so it's time for me to go to sleep. Perhaps somebody else can help you if you have more questions.[/quote]

thanks skunkbad.. i will more learn for php & mysql




Theme © iAndrew 2016 - Forum software by © MyBB