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. 


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

// 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">

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

while ($entry = mysql_fetch_array($entries)) {
  $id       = $entry["id"];
  $seminartitle = htmlspecialchars($entry["title"]);

  $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 ) {

  } else {

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

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


-----Original Message-----
From: Bogdan Stancescu [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 04, 2002 7:25 PM
To: Yuan Lu
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...


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
>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
>missed the name of the speaker field. Of about 80 records, I have 10
>have this problems.
>Does anyone have any idea what's going on here?
>Thanks for the help.
>Yua Lu

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to