| | |
php mySQL Problem
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Dec 2007
Posts: 4
Reputation:
Solved Threads: 0
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!
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)
Use simple select queries to list the programs. Then use the p_id value to list single program and the comments for the 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.
PHP Syntax (Toggle Plain Text)
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.
PHP Syntax (Toggle Plain Text)
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.
Last edited by FireNet; Dec 20th, 2007 at 12:45 am.
![]() |
Similar Threads
- Apache (Linux Servers and Apache)
- php mysql problem (PHP)
- PHP-MySQL Conn Problem in Win XP (PHP)
- PHP + MySQL Problem (PHP)
- installing php and mysql properly (Windows Servers and IIS)
- php phpmyadmin problem ?? (PHP)
- php mysql help (PHP)
- Port 80 problem (Linux Servers and Apache)
- Using PHP, MySQL and Apache Server (PHP)
Other Threads in the PHP Forum
- Previous Thread: Select matching records
- Next Thread: Retriving value through url
| Thread Tools | Search this Thread |
301 access apache api array beginner binary broken button cakephp checkbox class clean cms code countingeverycharactersfromastring crack cron curl database date decode directory display dissertation dropdown dynamic echo email error fairness file files folder form forms function functions google href htaccess html image include insert integration ip javascript joomla limit link login mail match md5 menu methods mlm multiple mysql newsletters oop pageing pagerank paypal pdf php problem protocol query radio random recursion remote script search secure server sessions simple sms soap source space spam sql syntax system table tutorial update upload url validator variable video virus votedown web youtube





