SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Zealot webhost's Avatar
    Join Date
    May 2001
    Location
    Il
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    FAQ Database Query

    Read my last post below.
    Last edited by webhost; May 3, 2003 at 16:22.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    whoa, that's hard on the brain

    what you want is accomplished by sql alone

    i don't understand why you are only querying the count() in your tables -- where's the query that actually returns the categories and answers?

    also, how did you want to select the 10 to show -- lastest? random? alphabetical?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot webhost's Avatar
    Join Date
    May 2001
    Location
    Il
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is a file from modernbill faq which is inside modernbill. I have this also working as standalone outside modernbill, but I only want to show certain categories like pre sales questions and uploading files and such. The way it is now I have to show all of them on the page.

    http://realwebhost.net/table.html

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    which questions and categories do you want to select?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Zealot webhost's Avatar
    Join Date
    May 2001
    Location
    Il
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.realwebhost.net/faqs.php
    categories 3,5,6,9,10,20 all questions under them

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,250
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    Code:
    select cname, ctype
    	 , question, answer, timestamp
      from categories
    inner
      join questions
    	on categories.cid = questions.cid
     where categories.cid in (3,5,6,9,10,20)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  7. #7
    SitePoint Zealot webhost's Avatar
    Join Date
    May 2001
    Location
    Il
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Going different route here scraped that file and have 2 here getting closer but lost with the queries here they are.

    faq_categories
    PHP Code:
    <?php 
    $dbi
    mysql_connect('localhost','user','pass');
    mysql_select_db('dbname');
    $sql_get_faq_categories_txt "select cid,cname from faq_categories where cid IN (3,5,6,9,10,20)";
    $sql_get_faq_categories mysql_query($sql_get_faq_categories_txt,$dbi);
    if (!
    $sql_get_faq_questions)
    die (
    "Error displaying information. Please report this information to the administrator -- ".$sql_get_faq_categories_txt " - " mysql_error());
    while(list(
    $cid,$cname)=mysql_fetch_row($sql_get_faq_categories))
    {
    echo 
    "<a href=""\"questions.php?cid=$cid\">$cname</a>";

    ?>
    faq_questions
    PHP Code:
    <?php 
    $dbi
    mysql_connect('localhost','user','pass');
    mysql_select_db('dbname');
    $sql_get_faq_questions_txt "select fid,cid,question,answer,timestamp from faq_questions";
    $sql_get_faq_questions mysql_query($sql_get_faq_questions_txt);
    if (!
    $sql_get_faq_questions)
    die (
    "Error displaying information. Please report this information to the administrator -- ".$sql_get_faq_questions_txt " - " mysql_error());
    while(list(
    $fid,$cid,$question,$answer,$timestamp)=mysql_fetch_row($sql_get_faq_questions))
    {
    // Display your information here

    ?>
    Last edited by webhost; May 3, 2003 at 16:29.


Bookmarks

Posting Permissions

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