SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: probs :(

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Wolverhampton, UK
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    probs :(

    won't print the results at the end of the script :
    Code:
    <?php
    # news.php
    
      $perpage = 10; #number of posts to be shown per page
      $result = mysql_query("SELECT * FROM news,members WHERE news.mid = members.id ORDER BY news.id DESC");
      $posts = mysql_num_rows($result); #number of posts in the db
    
      if(!$posts){
           echo("&rsaquo;&rsaquo;&rsaquo; No news at the present time<br><br> Please check back later... :D");
           die();
      }
    
      if(!$page){
           $page = 1; #set page number if not encrypted in url
      }
    
      if($posts - $page * $perpage >= 0){ #enough posts to fiil page?
          $first = $posts - ($page - 1) * $perpage;
          if($first > $posts){
              echo("Errrrmmmm, you on a page with no news, there haven't been enough posts to get to this page yet :D");
          }
      }
      else{
           $first = $posts % $perpage;
           $perpage = $first; #limits loops through while so only loops while still posts to print
      }
    
      $row_id = mysql_data_seek($result, ($first - 1)); # set the pointer to where it should start it's news loop
      $row = mysql_fetch_array($result);
    
      $i = 0; #set variable to control while loop
      while($row = mysql_fetch_array($result)){
      if($i < $perpage){
      echo($perpage);
      ?>
        <table width="390" bgcolor="#336666" width="390" cellpadding="0" cellspacing="1" border="0">
         <tr>
          <td width="308" bgcolor="#3399CC" align="left" class="mainnews">&nbsp;:: <?php echo($row["news.title"]); ?></td>
          <td width="82"  bgcolor="#3399CC" align="right" class="mainnews"><?php echo($row["news.date"]); ?>&nbsp;</td>
         </tr>
        </table>
        <font color="#006666">&rsaquo;&rsaquo;&rsaquo; posted by<a href="mailto:<?php echo($row["members.email"] . "\">" . $row["members.name"]); ?></a></font><br>
        <?php echo($row["news.body"]); ?><br>
      <?php
        $i++;
      }
      }
    ?>
    hlp,
    beachball

  2. #2
    SitePoint Zealot NZ Joe's Avatar
    Join Date
    Apr 2001
    Location
    Kapiti, New Zealand
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does it print anything? What HTML is generated? Do you get an empty table, or nothing at all?
    Gravity always wins

  3. #3
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <?php echo($row["news.body"]); ?>

    thinks that your problem... cant have the "." in there... if u are using a join, and u have to tables that have the field body in it, u might (as far as I know) have to get the numeric index for that field ie. $row[6]
    other wise I would try to take out the news and the period

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    Wolverhampton, UK
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no need now sorted it
    waaaaaaaaahhhhhhhhh

    the probs were:
    a) used mysql_fetch_array twice for the same set of results and and so screwed up wumhow, mite of gone onto second piece of news when i called it again buta as there is only one piece of news...
    b)also that "." join were wrong, thanx slightlywhacked for that...

    wooohooo me first workin' script
    i am so proud

    beachball


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
  •