Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-13-2003, 09:21 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Article Sys Mysql Help

Hi all im working on an article system for artorg and so far its coming along nicely, my problem is how would i get

the mysql to say get all the articles from a certain category

the article category is a sep table as i couldnt hav to auto increments in 1 table

i need it to get all the articles inserted into a cateogry and arrange the then resulting articles by there seperate tables id,

then once the link is clicked it,ll just load the article with that id (this i can do its the part before with th categorys im stuck at)

ive kind a fleshed out 90% of the code i just need some hlp with this..

also if anyone wants to take my code and develop it further/better for me then be my guest


these are the two mysql table im using sorry if there badly done i know f### all about mysql really

PHP Code:

  $DB_site
->query ("CREATE TABLE articlesystemcat (
  catid int(5) NOT NULL auto_increment,
  catname varchar(60) NOT NULL,
  PRIMARY KEY (catid)
 )"
);
  
  
$DB_site->query ("CREATE TABLE articlesystem (
  artid int(5) NOT NULL auto_increment,
  artname varchar(60) NOT NULL,
  artfull varchar(255) NOT NULL,
  artdate varchar(60) NOT NULL,
  artauth varchar(60) NOT NULL,
  artpword varchar(60) NOT NULL,
  PRIMARY KEY  (artid)
  
 )"
); 
Reply With Quote
  #2  
Old 05-13-2003, 10:11 PM
JulianD's Avatar
JulianD JulianD is offline
 
Join Date: Jan 2002
Posts: 455
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you should read more about relational databases.

There is no way to write a query to get all the articles on a specific category, because there's no relationship between the two tables.

You need to add an extra field to your articlesystem table (for example, catid) so you can have a relation between articlesystem and articlesystemcat. And now, with every article on the articlesystem table, you will have the correct category id for that article.

I hope you understand me
Reply With Quote
  #3  
Old 05-13-2003, 10:17 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

see my original idea was to have to id fields in one table catid and artid but it wouldbt allow this as they were both auto increment..

how could i achieve 2 ids in one table?

or am i bs`ing throught being stupid and not understanding lol?
Reply With Quote
  #4  
Old 05-13-2003, 10:37 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

anyone wanna help me code this lol..
Reply With Quote
  #5  
Old 05-13-2003, 10:42 PM
JulianD's Avatar
JulianD JulianD is offline
 
Join Date: Jan 2002
Posts: 455
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The field 'catid' on the articlesystemcat table is autoincrement... But you can add a field called 'catid' on the articlesystem table and it doesn't need to be an auto increment field. THe catid field on the articlesystem table will only have the category id number for every article...

Like this:

Code:
TABLE: articlesystem 
---------------------------
artid catid artname artfull
  1     1   my life  This is the history of my life...
  2     1    kevin!  About my brother kevin...
  3     2    PHP     A mini PHP manual..

Code:
TABLE: articlesystemcat
------------------------
catid catname
  1    Personal life
  2    Programming stuff...


You see the relationship between the two tables?
Reply With Quote
  #6  
Old 05-13-2003, 10:47 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so by adding that it should allow for it to work on the basis

cat = 1
article1 = 1 . 1
article2 = 1 . 2

is that basucally it soz if i seem like an idiot..

so if thats the case woul di just add and addition $catid and catid in the mysql insert when creating a new article?

and this would work fine?

i assume as cat id was already set up as an auto increment in the other table it would then just insert its value again this new query?

also if this is the case how would i then query it to show the articles for the category?
Reply With Quote
  #7  
Old 05-14-2003, 02:48 PM
colicab-d's Avatar
colicab-d colicab-d is offline
 
Join Date: Dec 2002
Location: Glasgow
Posts: 382
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bumpty bump bump
Reply With Quote
  #8  
Old 05-14-2003, 09:25 PM
JulianD's Avatar
JulianD JulianD is offline
 
Join Date: Jan 2002
Posts: 455
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Yesterday at 07:47 PM colicab-d said this in Post #6
so by adding that it should allow for it to work on the basis

cat = 1
article1 = 1 . 1
article2 = 1 . 2

is that basucally it soz if i seem like an idiot..

so if thats the case woul di just add and addition $catid and catid in the mysql insert when creating a new article?

and this would work fine?

i assume as cat id was already set up as an auto increment in the other table it would then just insert its value again this new query?

also if this is the case how would i then query it to show the articles for the category?
Yeah, you're getting the idea...

Now, let's suppose you already has the catid field on your articlesystem table.
Then, you would query the server like this:

[sql]
SELECT * FROM articlesystem WHERE catid=1
[/sql]

and you will get all the articles on the category id #1.
Reply With Quote
  #9  
Old 05-14-2003, 09:48 PM
pie pie is offline
 
Join Date: May 2003
Location: Devon, England
Posts: 226
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok i will try this, just gotta code in the cat id to its new home and figure out i can get the form for submission to include the ids for the article to be inserted to, in saying that tho a simple few querys will fix that up

hmm julian you wanna add me on msn? colicab@artorg.co.uk
Reply With Quote
  #10  
Old 05-14-2003, 09:53 PM
pie pie is offline
 
Join Date: May 2003
Location: Devon, England
Posts: 226
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

soz im on my cousin computer but is me colicab-d lol
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:12 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03949 seconds
  • Memory Usage 2,257KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete