heres the deal, i have created a table called tvprograms on a mySQL database and have added the fields id, program and comments and have populated the database.

The first thing i need to do is list just the programs in a php form but not the comments.

I then need to allow the user to select one of these programs and then display programs comments.

And finaly i need to allow the user to add a new program and comment to the database.

Can anyone help me with this as my coding is pretty poor!

Thanks guys

Merry Christmas!

If you need multiple comments, use 2 tables. One for the program details, and one for the comments. Use an id tag (preferably the unique key from the program details)

CREATE TABLE tvprograms (
p_id int(11) NOT NULL UNIQUE AUTO INCREMENT,
p_name char(40),
p_desc tinytext,
p_misc tinytext
);

CREATE tvprograms_comment(
pc_id int(11) NOT NULL UNIQUE AUTO INCREMENT,
p_id int(11) NOT NULL,
pc_text text
);

-- SQL QUERY MAY CONTAIN ERRORS

Use simple select queries to list the programs. Then use the p_id value to list single program and the comments for the program.

SELECT * FROM tvprograms ORDER BY p_id DESC LIMIT 5; -- to list last 5 programs

SELECT * FROM tvprograms WHERE p_id=' $X '; --- to select one program

SELECT * FROM tvprograms_comment WHERE p_id=' $X '; -- to select all the comments for a single program.

I hope you get the idea how the 2 tables are being used to do what you need. One stores all the program details and the second stores all the comments, with each comment being tagged with an id number from the program details table.

to get the programs
you can try this
$aq = " select * from tvprograms";
$sh = mysql_query($aq);

$n = mysql_numrows($sh);
for($i = 0; $i < $n; $i++)
{$pro = mysql_result($sh,$i,"fieldname");
//here give link
}

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.