All the output is generated from one big while loop. If some records
have all the information displayed properly, so should the other
records. I also checked the HTML output, everything seems all right.
I am really puzzled. Below is part of my script that display the records.
The script shows everything correctly except some records have the firstname
and lastname fields empty (but they do have valid value). 

Please help me. 

<?php

$dbcnx = mysql_connect("localhost", "root", "myfakepswd");
mysql_select_db("seminardb");

// The basic SELECT statement
$select = "SELECT * ";
$from   = " FROM seminars";
$where  = " WHERE id > 0";

if ($firstname != "") { // firstname is selected
  $where .= " AND firstname LIKE '%$firstname'";
}

if ($lastname != "") { // lastname is selected
  $where .= " AND lastname LIKE '%$lastname%'";
}

if ($absid != "") { // An abstract is selected
  $where .= " AND id=$absid";
}

if ($searchtext != "") { // Some search text was specified
  $where .= " AND title LIKE '%$searchtext%'";
}

$where .=" order by datestr desc";

?>

<table bgcolor="#000000" width=450 cellpadding=3 cellspacing=1
align="center" border="0">

<?php
$entries = mysql_query($select . $from . $where);
if (!$entries) {
  echo("</table>");
  echo("<p>Error retrieving seminars from database!<br />".
       "Error: " . mysql_error() . "</p>");
  exit();
}

$i=0;
while ($entry = mysql_fetch_array($entries)) {
  $id       = $entry["id"];
  $sol=htmlspecialchars($entry["solute"]);
  $first=htmlspecialchars($entry["firstname"]);
  $last=htmlspecialchars($entry["lastname"]);
  $middle=htmlspecialchars($entry["middlename"]);
  $position=htmlspecialchars($entry["position"]);
  $affil=htmlspecialchars($entry["affiliation"]);
  $seminartitle = htmlspecialchars($entry["title"]);
  $datestr=htmlspecialchars($entry["datestr"]);
  $timestr=htmlspecialchars($entry["timestr"]);
  $location=htmlspecialchars($entry["location"]);
  $abs=htmlspecialchars($entry["abstract"]);
 
  list($year,$month,$day)=sscanf($datestr,"%d-%d-%d");

  $jday=GregorianToJD($month, $day, $year);
  $mthname=jdmonthname($jday, 0);
  $wkday=jddayofweek($jday, 2);

  $text="<p>$wkday, $mthname $day, $year, ";
  if ( ! strstr($timestr, '10:') ) {
      $text .="<font color=\"#ff0000\">$timestr </font>, "." $location</p>";
  } else {
      $text .="$timestr, "." $location</p>";

  }
  if ( !($sol) ) {
     $text="$text"."<p>$sol"." $first"." $middle"." $last,";
  } else {
     $text="$text"."<p>$firstname"." $middlename"." $lastname,";
  }

  $text="$text"." $affil</p>";
  if ( $abs ) {

     $text="$text"."<p><a
href='seminar.php?absid=$id'>$seminartitle</a></p>";
  } else {
     $text="$text"."<p>$seminartitle</p>";
  }

  if ( $absid == $id ) {
     $abs=chop($abs)."<br>";
     $text .= "<p>$abs</p>";
  };

  echo("<tr valign='baseline'> ");
 
  if ( $i ) { 
     echo("<td bgcolor='#eeeeee'>$text</td>\n");
     $i=0;
  } else {
     echo("<td bgcolor='#eeeeff'>$text</td>\n");
     $i=1;
  }
  echo("</tr>\n");
}
?>

</table>

-----Original Message-----
From: Bogdan Stancescu [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 04, 2002 7:25 PM
To: Yuan Lu
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] PHP and SQL help


Take a look at the source HTML in your browser - you may be getting some 
"<" for example which would do that.

I really can't tell what it is for sure, but looking at the HTML source 
is generally a good idea...

Bogdan

Yuan Lu wrote:

>I am new to PHP and MySQL, and appreciate your help greatly.
>
>I create a simple one table database to list the seminar list. The fields
>are name of the speaker and the title along with other information. I used
>phpMyAdmin-2.2.1 to input the data and see that all the fields , including
>the fields that I couldn't get the values as described below, have proper
>values.
>
>When I retrieve all the fields from the same database from my little PHP
>program and display the result on a webpage (I use "select * from seminars
>order by datestr desc" to retrieve the records), I noticed that some
records
>missed the name of the speaker field. Of about 80 records, I have 10
records
>have this problems.
>
>Does anyone have any idea what's going on here?
>
>Thanks for the help.
>
>Yua Lu
>
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to