Jump to content

Archived

This topic is now archived and is closed to further replies.

Nifty

Access/ODBC. Drops last (newest) record from results

Recommended Posts

I am reasonably new to PHP. Had to convert a heap of MySQL to ODBC. It works but drops the last (newest) row from the results. I have no idea why... anyone?

            <?

$connectionstring = odbc_connect("DB", "", "");

 

if (isset($_GET["id"])) {

   $query = "SELECT * FROM notes WHERE note_id = $_GET[id]";

   $result = odbc_exec($connectionstring,$query);

   While( $rows = odbc_fetch_array($result) ) {

      $note_id = $rows['note_id'];

      $note_title = $rows['note_title'];

      $note_content = $rows['note_content'];

      $note_date = $rows['note_date'];

  $note_date = strtotime($note_date);

  $note_date = date("l, jS F, Y", $note_date);

  $note_content = str_replace("/n", "<br>", $note_content);

      $note_content = stripslashes($note_content);

  $note_link = $rows['note_link'];

      //Display results

      echo("<p><span class=noteheading>$note_title</span><br>");

      echo("<span class='notedate'>$note_date</span><br>");

  echo("<br>");

      echo("$note_content</p>");

  if ($news_link= "") {

     if (!strpos($note_link,"http://")) {

    $link="http://".$note_link;

} else {

    $link=$note_link;

}

     echo("<p><b>For further information go to <a href='".$link."' target='_blank'>". $note_link . "</a></b></p>");

  }

  echo("<br clear='all'>");

   }

   echo("<p><a href='index.php'>« Back to Items</a></p>");

   

} else {

$connectionstring = odbc_connect("Intranet", "", "");

$query = "SELECT * FROM notes WHERE (Date()-60) <= note_date ORDER BY note_date DESC, note_id DESC";

 

   }

  $result = odbc_do($connectionstring, $query);

 

if (odbc_fetch_array($result)== "") {

echo "There are currently no Staff News items available.";

echo("<p><a href='../index.php'>« Back to Home Page</a></p>");

}

 

     While( $rows = odbc_fetch_array($result) ) {

      $note_id = $rows['note_id'];

      $note_title = $rows['note_title'];

      $note_content = $rows['note_content'];

      $note_date = $rows['note_date'];

  $note_date = strtotime($note_date);

  $note_date = date("l, jS F, Y", $note_date);

 

      $note_content = stripslashes(FirstPara($note_content));   // only show first paragraph of article

      //Display results

      echo("<p>");

      echo("<b><a href='index.php?id=$note_id'>$note_title</a></b><br>");

  echo("<span class='notedate'>$note_date</span><br>");

      echo("<span class='notecontent'>$note_content<br>");

      echo("<a href='index.php?id=$note_id'>Read full article »</a></span></p>");

 

   }

 

if ($result == "") {

echo $result;

echo "There are currently no items available";

echo("<p><a href='../index.php'>« Back to Intranet Home Page</a></p>");

}

 

?>color]

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.