I'm still a newb with php, and i've been messing with this for hours with no success.

First, heres the sql dump for the three tables I'm using here they are:

DROP TABLE IF EXISTS news;
CREATE TABLE news (
id int(10) unsigned NOT NULL auto_increment,
postdate timestamp(14) NOT NULL,
title varchar(50) NOT NULL default '',
newstext text NOT NULL,
PRIMARY KEY (id),
KEY postdate (postdate)
) TYPE=MyISAM;

DROP TABLE IF EXISTS news_category;
CREATE TABLE news_category (
category_id bigint(20) NOT NULL auto_increment,
PRIMARY KEY (category_id)
) TYPE=MyISAM;

DROP TABLE IF EXISTS category;
CREATE TABLE category (
category_id bigint(20) NOT NULL auto_increment,
category_name char(80) default NULL,
PRIMARY KEY (category_id)
) TYPE=MyISAM;

What i'm trying to do is give my news postings categories, so I can post news in categories and sort them out if a visitor wants to view only the specific ones posted in the category.

the INSERT query im using to insert just the news looks like this:

$result = mysql_query("INSERT INTO news (id, postdate, title, newstext)
VALUES ('$id',NOW(),'$title','$newstext')",$connect);

What sql query would I use if i was using form textboxes to send the datas?

Also, what query would i use to display each news with its category and when users click the category link in a menu, what would the sql query be to display the category with news?

Any tips or suggestions would be appreciated.

Thanks for the help :)

Use $_POST if you use a form and method of POST.
Use $_GET if you use querystring or using form with method of GET
Use $_REQUEST if you not sure about the method, of you use both query methods.

In your first case, using textboxes (in form I suppose), then using $_POST. In you second case, you may use link with query strings attach to it, for eg. /news.php?catgeory_id=12345, then use $_GET.

Hope this help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.