SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 32 of 32
  1. #26
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    tn
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I realize this is a mess:

    Code:
    <?php
    
    require 'db_connect.php';
    
    $query="SELECT * FROM users WHERE username ='$_SESSION[username]'";
    $result=mysql_query($query);
    
    $user_id=mysql_result($result,$i, "user_id");
    $username=mysql_result($result,$i,"username");
    
    mysql_close();
    
    ?>
    
    <HTML>
    
    <HEAD>
    <TITLE>Phasalistics Forums</TITLE>
    <META NAME="keywords" content="Phasalistics Forum Forums Community"> 
    <META NAME="description" content="Phasalistics Online Community for the Masses."> 
    <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <META http-equiv="Content-Style-Type" content="text/css">
    
    <STYLE TYPE="TEXT/CSS">
    
    .username { 
    background-color: transparent;
    font-family: verdana, arial, sans-serif;
    font-weight: bold;
    font-size: 12pt;
    color: #000000;
    text-decoration: underline; 
    text-align: left;
    } 
    
    .mainlink {
    background-color: transparent;
    font-family: verdana, arial, sans-serif;
    font-weight: bold;
    font-size: 10pt;
    color: #555555;
    text-decoration: underline;
    }
    
    .bold {
    background-color: transparent;
    font-family: verdana, arial, sans-serif;
    font-weight: bold;
    font-size: 11pt;
    color: #555555;
    text-decoration: none;
    }
    
    .sitemap {
    background-color: transparent;
    font-family: verdana, arial, sans-serif;
    font-weight: bold;
    font-size: 10pt;
    color: #555555;
    }
    
    .boardheading {
    background-color: transparent;
    font-family: verdana, arial, sans-serif;
    font-weight: bold;
    font-size: 10pt;
    color: #000000;
    }
    </STYLE>
    
    
    
    </HEAD>
    
    <BODY BGCOLOR="#939C91">
    
    <!--------------------- Top layer. Banner ads and logos ---------->
    
    <TABLE WIDTH="100%" border="1" CELLPADDING="0"> 
      <TR>
         <TD WIDTH="25%"><A HREF="home.php"><IMG SRC="images/image.gif" border="0"></A>
         <TD ALIGN="left">[Banner]
    </TR>
    </TABLE> 
    
    <!---------------- First layer of links ----------------->
    
    <BR>
    
    <TABLE border="0" CELLPADDING="0" ALIGN="center">
      <TR>
        <TD CLASS="bold"><A HREF="profile.php?id=<?php echo $user_id ?>" style="color:#000000;" CLASS="mainlink"><?php echo $username ?></A> | 
        <A HREF="inbox.htm" style="color:#333333;" CLASS="mainlink">Private Messages (New)</A> | 
        <A HREF="editprofile.php " style="color:#333333;" CLASS="mainlink">Edit Profile and Options</A> | 
        <A HREF="friendslist.htm" style="color:#333333;" CLASS="mainlink">Friends List</A> | 
        <A HREF="upgrade.htm" style="color:#333333;" CLASS="mainlink">Upgrade</A> 
      </TR>
    </TABLE>
    
    <TABLE border="0" CELLPADDING="0" ALIGN="center">
      <TR>
        <TD CLASS="bold">
        <A HREF="placeholder.htm" style="color:#333333;" CLASS="mainlink">Forum Rules</A> | 
        <A HREF="placeholder.htm" style="color:#333333;" CLASS="mainlink">FAQ</A> | 
        <A HREF="placeholder.htm" style="color:#333333;" CLASS="mainlink">Contact Mods</A> | 
        <A HREF="placeholder.htm" style="color:#333333;" CLASS="mainlink">Help</A> | 
        <A HREF="placeholder.htm" style="color:#333333;" CLASS="mainlink">Search</A>
      </TR>
    </TABLE>
    
    <!---------------- Site Map/Posting links--------------------------->
    
    <BR>
    <TABLE border="0" CELLPADDING="0" ALIGN="left">
      <TR>
        <TD class="sitemap" COLSPAN="3"><A HREF="home.php" class="sitemap">Phasalistics Home</A> > Forums
      </TR>
    </TABLE>
    
    <!-----------Threads Table---------------------->
    
    
    
    <BR><BR><BR>
    <TABLE WIDTH="100%" border="1" CELLSPACING="0" CELLPADDING="3" bgcolor="#D4D8D6">
      <TR ALIGN="left">
         <TD WIDTH="2%" CLASS="boardheading" Background="images/top.gif">+
         <TD WIDTH="73%" CLASS="boardheading" ALIGN="center" Background="images/top.gif">Category Titles
         <TD WIDTH="5%" CLASS="boardheading" ALIGN="center" Background="images/top.gif">Topics
         <TD WIDTH="5%" CLASS="boardheading" ALIGN="center" Background="images/top.gif">Posts
         <TD WIDTH="15%" CLASS="boardheading" ALIGN="center" Background="images/top.gif">Last post
      </tr>
    </table>
    
    <?php
    
    require 'db_connect.php';
    
    $query = mysql_query("SELECT * 
                          FROM categories 
                          ORDER BY order_id ASC"); 
    $row = mysql_num_rows($query) 
    $cat_id = $row[0]; // where row 0 is cat id 
    echo "<a href='forum.php?id=".$cat_id."'>".$row[1]."</a><br>"; // where row 1 is cat name 
    $ret = mysql_query("SELECT * 
                        FROM forums 
                        WHERE cat_id = '$cat_id' 
                        ORDER BY order_id ASC"); // cat is a field which is linked with cat id 
    $r = mysql_num_rows($ret); 
    for($j = 0; $j < $r; ++$j) { 
    $row = mysql_fetch_row($ret); 
    echo "<a href='forum.php?sub_id=".$row[0]."'>".$row[1]."</a><br>"; 
    } 
    } 
    
    mysql_close();
    
    ?>
    
    
    
    
    <br><Br>
    <center>
    <a href="placeholder.htm" style="color:#333333;">Terms of Service</a> &nbsp;&nbsp;&nbsp;
    <a href="placeholder.htm" style="color:#333333;">Privacy Policy</a> &nbsp;&nbsp;&nbsp;
    <a href="placeholder.htm" style="color:#333333;">Contact us</a> &nbsp;&nbsp;&nbsp;
    </center>
    
    
    </BODY>
    </HTML>

  2. #27
    SitePoint Evangelist pompopom's Avatar
    Join Date
    Feb 2004
    Location
    Huldenberg (Belgium)
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Phases
    Pom, what is $sn?
    $sn is the id of the subcategorie, in your case the forums
    The Path of excess leeds to the tower of wisdom (W. Blake)

  3. #28
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    tn
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a funny feeling if I can't get this little script to work, I certainly won't be able to pull off yours pompom...

    I've been workin on this for what... 13 hours now? Still no success. No progress even. That's how .....new.. I am.

    Kinda depressing. Fortunately Reminder has hung around and kept me company, but I think I've about wore him out!

  4. #29
    SitePoint Evangelist pompopom's Avatar
    Join Date
    Feb 2004
    Location
    Huldenberg (Belgium)
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Phases
    I have a funny feeling if I can't get this little script to work, I certainly won't be able to pull off yours pompom...

    I've been workin on this for what... 13 hours now? Still no success. No progress even. That's how .....new.. I am.

    Kinda depressing. Fortunately Reminder has hung around and kept me company, but I think I've about wore him out!
    Well I've been out ror the day, going to sleep now, tomorrow g2g to work.
    Never give up. When I started coding every code I read from other people over here confused me too. that's normal. everybody has a different way of logical thinking. I'll achieve a goal in a complete differetn way of coding as you will, and probably reminder will have a third version of how to do it.

    As far as I understand it now so far. You don't seem to manage to get your data correct out of the DB. So first try to do this correct then afterwards worry about the tree-foldout.

    this is your code; I fixed it up a bit

    PHP Code:
    <?php
    //connect to DB
    require 'db_connect.php';
    //query for the different categories
    $query="SELECT * FROM categories ORDER BY order_id ASC";
    $ok=mysql_query($query);
    if(!
    $ok)
    {die(
    'MySQL error'.mysql_error().'<br>');}
    //do loop while you have categories
    while($row=mysql_fetch_array($ok))
    {
     
    //echo main link
     
    echo "<a href='forum.php?id=".$row[cat_id]."'>".$row[cat_title]."</a><br>";
     
    //query for subcategories
     
    $query2="SELECT * FROM forums WHERE cat_id = '".$row[cat_id]."' ORDER BY order_id ASC";
     
    $ok2=mysql_query($query2);
     if(!
    $ok2)
     {die(
    'MySQL error'.mysql_error().'<br>');}
     
    //do loop while subcats present
     
    while($row2=mysql_fetch_array($ok2))
     {
      
    //&nbsp; is for indent
      
    echo "&nbsp;&nbsp;&nbsp;<a href='forum.php?sub_id=".$row[forum_id]."'>".$row[forum_name]."</a><br>";
     }
    }
    //close connection
    mysql_close();
    ?>
    normally this should work. post me a link to the site if it doesn't

    will be back in half an hour... see ya later on

    greetz,
    koen
    The Path of excess leeds to the tower of wisdom (W. Blake)

  5. #30
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u called twice db_connect into your file?
    what is that $i ?
    Code:
    $user_id=mysql_result($result,$i, "user_id");
    $username=mysql_result($result,$i,"username");
    u have cancel the while loop?
    what r u doing?

    ps pompopom when u call $row2 so u have to define it into echo $row2[blabla]
    cheers

  6. #31
    SitePoint Evangelist pompopom's Avatar
    Join Date
    Feb 2004
    Location
    Huldenberg (Belgium)
    Posts
    426
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by reminder
    u called twice db_connect into your file???
    what is that $i ???
    $user_id=mysql_result($result,$i, "user_id");
    $username=mysql_result($result,$i,"username");
    u have cantel the while loop???
    what r u doing!!!
    the double db_connect isn't a problem since he uses mysql_close(); each time, but your right it's unnessesary.

    the $i part indeed I didn't get that either that's why I deleted it and replaced it with a while loop

    greetz,
    koen
    The Path of excess leeds to the tower of wisdom (W. Blake)

  7. #32
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u had into your code 30000 errors!
    take this solved code..
    hth
    PHP Code:
    <?php
    session_start
    (); // i saw bellow ur using sessions
    include_once("db_connect.php");
    $query mysql_query("SELECT * FROM users WHERE username = '$_SESSION[username]'");
    $row mysql_fetch_row($query);
    ?>
    <HTML>
    <HEAD>
    <TITLE>Phasalistics Forums</TITLE>
    <META NAME="keywords" content="Phasalistics Forum Forums Community"> 
    <META NAME="description" content="Phasalistics Online Community for the Masses."> 
    <META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <META http-equiv="Content-Style-Type" content="text/css">
    <STYLE TYPE="TEXT/CSS">
    .username { 
    background-color: transparent;
    font-family: verdana, arial, sans-serif;
    font-weight: bold;
    font-size: 12pt;
    color: #000000;
    text-decoration: underline; 
    text-align: left;

    .mainlink {
    background-color: transparent;
    font-family: verdana, arial, sans-serif;
    font-weight: bold;
    font-size: 10pt;
    color: #555555;
    text-decoration: underline;
    }
    .bold {
    background-color: transparent;
    font-family: verdana, arial, sans-serif;
    font-weight: bold;
    font-size: 11pt;
    color: #555555;
    text-decoration: none;
    }
    .sitemap {
    background-color: transparent;
    font-family: verdana, arial, sans-serif;
    font-weight: bold;
    font-size: 10pt;
    color: #555555;
    }
    .boardheading {
    background-color: transparent;
    font-family: verdana, arial, sans-serif;
    font-weight: bold;
    font-size: 10pt;
    color: #000000;
    }
    </STYLE>
    </HEAD>
    <BODY BGCOLOR="#939C91">
    <!--------------------- Top layer. Banner ads and logos ---------->
    <TABLE WIDTH="100%" border="1" CELLPADDING="0"> 
      <TR>
         <TD WIDTH="25%"><A HREF="home.php"><IMG SRC="images/image.gif" border="0"></A>
         <TD ALIGN="left">[Banner]</td>
    </TR>
    </TABLE> 
    <!---------------- First layer of links ----------------->
    <BR>
    <TABLE border="0" CELLPADDING="0" ALIGN="center">
      <TR>
        <TD CLASS="bold"><A HREF="profile.php?id=<?php echo $row["user_id"]; ?>" style="color:#000000;" CLASS="mainlink"><?php echo $row["username"]; ?></A> | 
        <A HREF="inbox.htm" style="color:#333333;" CLASS="mainlink">Private Messages (New)</A> | 
        <A HREF="editprofile.php " style="color:#333333;" CLASS="mainlink">Edit Profile and Options</A> | 
        <A HREF="friendslist.htm" style="color:#333333;" CLASS="mainlink">Friends List</A> | 
        <A HREF="upgrade.htm" style="color:#333333;" CLASS="mainlink">Upgrade</A> 
      </TR>
    </TABLE><?php
    mysql_free_result
    ($query); // here u stop he first db output couse u echoed into script
    ?><TABLE border="0" CELLPADDING="0" ALIGN="center">
      <TR>
        <TD CLASS="bold">
        <A HREF="placeholder.htm" style="color:#333333;" CLASS="mainlink">Forum Rules</A> | 
        <A HREF="placeholder.htm" style="color:#333333;" CLASS="mainlink">FAQ</A> | 
        <A HREF="placeholder.htm" style="color:#333333;" CLASS="mainlink">Contact Mods</A> | 
        <A HREF="placeholder.htm" style="color:#333333;" CLASS="mainlink">Help</A> | 
        <A HREF="placeholder.htm" style="color:#333333;" CLASS="mainlink">Search</A>
      </TR>
    </TABLE>
    <!---------------- Site Map/Posting links--------------------------->
    <BR>
    <TABLE border="0" CELLPADDING="0" ALIGN="left">
      <TR>
        <TD class="sitemap" COLSPAN="3"><A HREF="home.php" class="sitemap">Phasalistics Home</A> > Forums
      </TR>
    </TABLE>
    <!-----------Threads Table---------------------->
    <BR><BR><BR>
    <TABLE WIDTH="100%" border="1" CELLSPACING="0" CELLPADDING="3" bgcolor="#D4D8D6">
      <TR ALIGN="left">
         <TD WIDTH="2%" CLASS="boardheading" Background="images/top.gif">+
         <TD WIDTH="73%" CLASS="boardheading" ALIGN="center" Background="images/top.gif">Category Titles
         <TD WIDTH="5%" CLASS="boardheading" ALIGN="center" Background="images/top.gif">Topics
         <TD WIDTH="5%" CLASS="boardheading" ALIGN="center" Background="images/top.gif">Posts
         <TD WIDTH="15%" CLASS="boardheading" ALIGN="center" Background="images/top.gif">Last post
      </tr>
    </table><?php
    $query 
    mysql_query("SELECT * 
                          FROM categories 
                          ORDER BY order_id ASC"
    ); 
    while(
    $row mysql_fetch_array($query)) { 
    $cat_id $row[0]; // where row 0 is cat id 
    echo "<a href='forum.php?id=".$cat_id."'>".$row[1]."</a><br>"// where row 1 is cat name 
    $ret mysql_query("SELECT * 
                        FROM forums 
                        WHERE cat_id = '
    $cat_id
                        ORDER BY order_id ASC"
    ); // cat is a field which is linked with cat id 
    while($row2 mysql_fetch_array($ret)) { 
    echo 
    "<a href='forum.php?sub_id=".$row2[0]."'>".$row2[1]."</a><br>"

    mysql_free_result($ret);

    mysql_free_result($query);
    ?>
    <br><Br>
    <center>
    <a href="placeholder.htm" style="color:#333333;">Terms of Service</a> &nbsp;&nbsp;&nbsp;
    <a href="placeholder.htm" style="color:#333333;">Privacy Policy</a> &nbsp;&nbsp;&nbsp;
    <a href="placeholder.htm" style="color:#333333;">Contact us</a> &nbsp;&nbsp;&nbsp;
    </center>
    </BODY>
    </HTML>
    cheers


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
  •