SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member nickthibert's Avatar
    Join Date
    May 2004
    Location
    Ottawa
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question selecting certain rows only

    what im trying to do here is add the ability to make certain galleries public, and some not. i have added a column to my database called 'public' witha set value of yes or no. now, what im trying to do is modify this code to select only the galleries that have 'yes' in the public column. this code is from the tutorial http://www.sitepoint.com/article/ph...ystem-minutes/1

    here's the code:
    PHP:

    if( empty($cid) && empty($pid) )
    {
    $number_of_categories_in_row = 1;
    $result = mysql_query( "SELECT c.category_id,c.category_name,COUNT(photo_id)
    FROM gallery_category as c
    LEFT JOIN gallery_photos as p ON p.photo_category = c.category_id
    GROUP BY c.category_id"
    );
    while(
    $row = mysql_fetch_array( $result ) )
    {
    $result_array[] = "<a href='view_memb_fros.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[2].")";
    }
    mysql_free_result( $result );
    $result_final = "<tr height='20' width='300' align='center' valign='middle'>";
    foreach(
    $result_array as $category_link)
    {
    if(
    $counter == $number_of_categories_in_row)
    {
    $counter = 1;
    $result_final .= "</tr><tr height='20' width='300' align='center' valign='middle'>";
    }
    else
    $counter++;
    $result_final .= "<td height='20' align='center' valign='middle'>".$category_link."</td>";
    }
    if(
    $counter)
    {
    if(
    $number_of_categories_in_row-$counter)
    $result_final .= "<td height='20' align='center' valign='middle'>&nbsp;</td>";
    $result_final .= "</tr>";
    }
    }


    any ideas anyone? whenever i try to to add in a WHERE statement in the mysql query, i get different errors returned (mostly invalid array functions).

    any help is greatly appreciated!

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,215
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •