Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php and mysql problem; mostly mysql

Status
Not open for further replies.

rninja

Technical User
Apr 11, 2001
381
US
I have a php script that is a faq script. I have one table where it holds posts and another that holds titles. I am having a problem tying the post_id with table_id. In the titles table I have title_id auto incrementing and the posts table holds the post_id which auto increments, and a title_id which is supposed to be tied to the post_id so that when bringing up the title, the post can also be tied to the post.

Right now the title_id in the post table gets a "0" always for each post, never tied with any title. So I get blank posts where there should be answers. I don't know what to do at this point to get the two working.

I appreciate any help with this!

Rninja

smlogo.gif

 
You should just have your title table ID autoincrement and have it as the primary Key then you you have the title Id and the title is selected the copy that primary into the post table as the post ID this will link your tables together correctly

Dave
ToeShot@Hotmail.com
Today Is Tomorrows Yesterday. So Why Wait
 
I didn't understand what you said, but I appreciate the quick post!

Let me re-state how I have my tables. Here is a diagram:

DATABASE--> itsafaq
| topics posts
------ -----
(pkey/autoi) topic_id post_id (pkey/autoi)
topic_title topic_id
topic_owner post_text
post_owner

When a php page is generated in the faq, it displays the topic_title and the post_text/post_owner. I am getting a "0" in the database where the topic_id (posts table), is supposed to have the same topic_id that was set in topic_id (topics table). Does anyone know how I can go about doing that? I am unsure as to whether I need to have that coded in php or if that can be addressed in mysql.

I appreciate your help!

Rninja

smlogo.gif

 
Notice the change I made the PostID should match the TopicID that the post is for. for example topic ID is 12 and the topic is dairy products then the post ID should be 12 for milk and 12 for cheese etc, were as post on steak would have and postid of 13 if the topicid of meat was 13. This will keep your topics and post to those topics linke when you rune queries.

DATABASE--> itsafaq
| topics posts
------ Link -----
(pkey/autoi) topic_id <---> post_id (pkey/longInt)<-change
topic_title topic_id
topic_owner post_text
post_owner


Dave
ToeShot@Hotmail.com
Today Is Tomorrows Yesterday. So Why Wait
 
I tried setting the post table field of post_id to primary key and longint/bigint, but it made no difference. It did exactly the sae thing. I don't understand why it is not working, they both use the title_id as a link in structure.

Rninja

smlogo.gif

 
do you have the code that you are using so I could look at that?

Dave
ToeShot@Hotmail.com
Today Is Tomorrows Yesterday. So Why Wait
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top