Page 3 of 3 FirstFirst 123
Results 33 to 44 of 44

Thread: More database fun

  1. #33
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    In answer to your other question, it's up to you. If you feel that having all the content in one field is the best way to go then do that. Another approach would be to have another table called item_pages which is linked to items. items stores the details about the item and item_pages stores the content for each page. This would only be of any use if your articles are going to be several pages long

  2. #34
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    ok, i can make item_pages yeh, sometimes some of the tutorials will be put on multiple pages. Only problem is getting page numbers to display at the bottom of the page. It may take some troubleshooting.

    With the fact to return the info using the same page, yeh that's what i wanted to do, i just wasn't sure if it was possible. So i can query from another page and get it to display on that page? i.e. article.php?section=1&category=photoshop&ID=2

    So i would catch the URL to make it display the info from the db?

    Still not sure why the author won't appear, i tried changing the table name to author but this still was not the problem. I'll have to check up on it

  3. #35
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    If you;re going direct to an article you only need article.php?ID=2

    The rest of the information should be in the database against the item anyway so you can get it when you open the page, no need to put it in the URL

  4. #36
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Ok, so if i click on "tutorials, articles or reviews" i want the page to display the categories of that page. So far i've come up with this as i want it to display the amount of rows linked to that particular category to show how many tutorials, reviews or articles there are. This still isn't finished as i can't get my head around some stuff. I still have to link the $row['category'] yet.

    PHP Code:
    $query "SELECT ID FROM items"$result mysql_query ($query
    or die (
    '<p>'mysql_error() .'</p><p>'$query .'</p>'); $sum mysql_num_rows ($result);

    $sql mysql_query("SELECT category FROM items");
    while(
    $rowmysql_fetch_array($sql)){
    print 
    "<b>".$row['category']."</b>" $result;

    Any ideas? I would imagine i would do <a href= around the $row['category'] and link it to the ID of that category but i would also need to tell it "this category in only this section" so not sure about that one.

  5. #37
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    Without seeing the full code and the database design and content it's impossible to say what you need. My guess is something similar to the code below. Note, if an item does not always have a category then you need a LEFT JOIN in your SQL.


    PHP Code:
    $query "SELECT count(items.ID) AS cat_count, categories.category 
        FROM items, categories
        WHERE items.item_types_ID = "
    .$_GET["ID"]." AND items.categories_ID=categories.ID
    GROUP BY items.categories_ID"
    ;
        
        
    $result mysql_query($query);
        
        while (
    $row mysql_fetch_array($result))
        {
            echo 
    $row["category"]." (".$row["cat_count"]." items)<br />";
        } 

  6. #38
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Well i could give you access, can i trust you though?

  7. #39
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    yes you can trust me, but it's entirely your choice

  8. #40
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Sure thing, i'll poke you when you're on IRC. Missed you last time i asked a question

  9. #41
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    ta for doing that az, i'll have a look over it when i'm sober

  10. #42
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Right, i've had another good look at it. Does this mean i don't need the switch? As long as i've got the ID of the item_types then it still works fine?

  11. #43
    HEXUS.net Webmaster
    Join Date
    Jul 2003
    Location
    UK
    Posts
    3,108
    Thanks
    1
    Thanked
    0 times in 0 posts
    no switch is needed, just use the code i put in the file

  12. #44
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Right, i'm going to start working on it again, i had a break 'cause i got sick of it from working on it so much

    I still need to understand how to be able to click on the categories and it take me into the list and then click on an item in the list to take me into a tutorial. Although this is the complicated way to do, it's just the way i want it done

    PHP Code:
    echo "<a href=\"id=" $line['id'] . "&category=" $line['category'] . "\">"
     
    $line['title'] . "</a> by " $line['author'] . ", posted on the: " $line['date'] .
     
    "<br><blockquote>" $line['explanation'] . "</blockquote>"
    So something along those lines but simpler for displaying all the tutorials in that category.

    PHP Code:
    echo $row["category"]." (".$row["cat_count"]." items)<br /><br />"
    If that's what i've got, i'll probably need to put

    PHP Code:
    <href=\"id=" $line['id'] . "&category=" $line['category'] . "\">" 
    I would then put what is to be displayed such as the category and how many items are in that category. I would have to link to a seperate file right?

    It's all very confuzzling

Page 3 of 3 FirstFirst 123

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
  •