Page 2 of 3 FirstFirst 123 LastLast
Results 17 to 32 of 44

Thread: More database fun

  1. #17
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    your query is working, it's just not returning any results hence when you try to loop through them you get that error. Just echo the query onto the page then paste it into your SQL editor to tweak it and find out what's wrong. If I had to guess I'd say your item_types table IDs don;t match the ones in your items table if you're using the same structure I suggested

  2. #18
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    ugh, why don't they match?

    /me looks over

  3. #19
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    argh gonna give up soon

    I don't understand how the relationship works between those tables that you showed me neither do i see how they could work

    Can i not stick to my original table and use the switch to specify a certain field?

    Help pretty please, i just want my site up and running

  4. #20
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    the ID in the item_types table needs to match the item_types_ID field in the items table. Remember I only guessed at the problem. It would be impossible to debug without seeing your database and code and therefore might be something completely different

  5. #21
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    there's no item_types_ID in the items table, only an ID field. So to match i need to change the ID field in the items table to item_types_ID ?

  6. #22
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    my fault, I missed it out the SQL statements. You need another field in items
    Run this SQL

    ALTER TABLE `items` ADD `item_types_ID` INT( 11 ) NOT NULL ;
    ALTER TABLE `items` ADD INDEX ( `item_types_ID` )

    You should really learn how databases work though or you will encounter even more problems later

  7. #23
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Yeh i know, i'm terrible for it but i've got a "book for dummies" on it which really doesn't help as it shows the most basic database structure there is possible. You got any recommendations?

  8. #24
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    OOh looks like it worked. Now i've just got to understand this database structure. Do you think there's anything on devshed?

  9. #25
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    I learnt my database knowledge through practice and some training courses at work. The best books imho are the Sitepoint one. Best place to start would be http://www.sitepoint.com/books/phpmysql1/

    You can download the frst 4 chapters for free to give you an idea. I've bought all their PHP books and in the main they have been excellent

  10. #26
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    ah cheers. I've got to get some more soon.

    Right now i've (you've) got the database working i've just got to figure out the relationship.

    I guess categories would be either "articles", "tutorials" or "reviews" or it could be the categories of every section. Then item_types would be articles, tutorials or reviews.

  11. #27
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    no point in item types and categories being the same thing. item types should be as you said, categories should be the item category e.g. for Hexus it might be motherboard, graphics card, CPU, soundcard, etc for our reviews

  12. #28
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Ah right, i see. So could using this for the other pages work as well? For example, the news page, about page and so forth? I think i need to get to work on it and test it before i ask anything else

    I'll make sure a nice big hexus banner goes on the front page

  13. #29
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    Static pages such as the about page are best left as standalone pages. Depending on your content it might also be worthwhile making news a separate table and page. This means that your database won't need to trawl through a large table of articles, tutorials and news just to extract the news which means the front page would be faster.

    You could still link news to the categories table though

  14. #30
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Right i've got the relations sorted for the different tables in comparison to the article.php file. Now, the field in the "items" table called "explanation" is meant to be a 'snippet' of what's about to be displayed?

    If so, should i create a new field which links to another table for the content? Or is that "explanation" field for the content?

    It now displays some text in the "tutorials" section, for some reason the user table isn't relating to the "item" table correctly. The ID's are correct so i'm not sure why it's not working. I'll have to look back to the article.php file

  15. #31
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Ok i could use:

    PHP Code:
    echo "<a href=\"read_article.php?id=" $line['id'] . "&category=" $line['category'] . "\">" $line['title'] . "</a> by " $line['author'] . ", posted on the: " $line['date'] . "<br><blockquote>" $line['explanation'] . "</blockquote>"
    This way it would take you to the read_article.php page then it would catch the URL and use it to display the information

    Good idea?

  16. #32
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    yeah but didnt you want one page to handle all items (except possibly for news ?)

    Even so, all you need is the ID part. Once you open read_article.php you can query for the item with that ID and return the category anyway, no need to put it in the URL

Page 2 of 3 FirstFirst 123 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 11-09-2003, 03:43 PM
  2. hexus database
    By ingouk in forum HEXUS Suggestions
    Replies: 4
    Last Post: 08-09-2003, 09:46 PM
  3. having loads of fun with viruses...
    By scottyman in forum Software
    Replies: 17
    Last Post: 23-08-2003, 03:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •