On 10/8/05, Pete <[EMAIL PROTECTED]> wrote:
>  In message
> <[EMAIL PROTECTED]>,
>  Charles River <[EMAIL PROTECTED]> writes
>  >Sorry, with just one table, I tend to use the words table and database
>  >interchangeably.
>
>  Naughty boy... there is a difference   <G>

And the difference is????
>
>  >I have two addition scripts. One accepts a string and searchs the
>  >table for the row that contains a match and the secind displays that
>  >row. How do I get the updated time to appear in the display of the
>  >second script?
>
>  As you have already done it in one script, I can't understand why you
>  can't do it in the second script.  You will need two queries.
>
>  If the idea of two queries does not help you, then please post some
>  code.

Thanks. Here are the two scripts...

===============

<?php
  /* Program: SearchDir.php
   * Desc:    Permits searching the resident directory
   */
?>
<html>
<head><title>Directory Search</title>
<link href="dir.css" rel="stylesheet" type="text/css">
</head>
<body>
<body>
<?php
function convert_datetime($datestamp, $format) {
    if ($datestamp!=0) {
        list($date, $time)=split(" ", $datestamp);
        list($year, $month, $day)=split("-", $date);
        list($hour, $minute, $second)=split(":", $time);
        $stampeddate=mktime($hour,$minute,$second,$month,$day,$year);
        $datestamp=date($format,$stampeddate);
        return $datestamp;
    }
}
?>
<?php
  include("login.inc");                                           // 11

  $connection = mysql_connect($host,$user,$password)             // 13
       or die ("couldn't connect to server");
  $db = mysql_select_db($database,$connection)                   // 15
       or die ("Couldn't select database");

  /* Select all categories from table */
  $query = "SELECT * FROM $table";             // 19
  $result = mysql_query($query)                                  // 20
       or die ("Couldn't execute query.");

  /* Display text before form */
  echo "<div style='margin-left: .1in'>";
  echo "<h2>Directory Search</h2>";
  echo "<h3>Search the Resident directory by <br>name, street or email
address.</h3>";

 /*
 $row = mysql_fetch_array($result,MYSQL_ASSOC);
$newtime = convert_datetime($row['Update_time'], "M d, Y");
echo "<h3> Directory was updated on {$newtime} </h3>\n";
*/

  echo "<form action='ShowDir.php' method='post'>\n";          // 34
  echo "<p>Enter search item: ";
  echo "<input type='text' name='search_string' size='20'>";
  echo "<input type='submit' value='GO!'> </form>\n";                 
                           // 55
?>
</div>
</body>
</html>
====================================

<?php
  /* Program: ShowDir.php
   * Desc:    Displays results of the search.
   */
?>
<html>
<head><title>Search Results</title>
<link href="dir.css" rel="stylesheet" type="text/css">
</head>
<body topmargin="0" marginheight="0">
<?php
  include("login.inc");

  $connection = mysql_connect($host,$user,$password)
       or die ("Couldn't connect to server");

  $db = mysql_select_db($database,$connection)
       or die ("Couldn't select database");

$sql = "SELECT * FROM $table ";
$sql .= "WHERE `Last` LIKE '%$search_string%' ";
$sql .= "OR `First` LIKE '%$search_string%' ";
$sql .= "OR `Other` LIKE '%$search_string%' ";
$sql .= "OR `Street` LIKE '%$search_string%' ";
$sql .= "OR `Email` LIKE '%$search_string%' ";
$sql .= "ORDER BY Street, Num, Last";

  $result = mysql_query($sql)
       or die ("Couldn't execute query.");

  /* Display results in a table */

    echo "<table cellspacing='0' border='1' cellpadding='2' width='100%'>";
    echo "<tr>\n";
    echo "<th>Last Name</td>\n";
    echo "<th>First Name</td>\n";
    echo "<th>Other</td>\n";
    echo "<th>Num</td>\n";
    echo "<th>Street</td>\n";
    echo "<th>Phone</td>\n";
    echo "<th>Email</td>\n";
    echo "</tr>\n";

  while ( $row = mysql_fetch_array($result,MYSQL_ASSOC) )
  {
    echo "<tr>\n";
    echo "<td>{$row['Last']}</td>\n";
    echo "<td>{$row['First']}</td>\n";

if ($row['Other'] == "") {
    echo "<td>-</td>\n";
} else {
    echo "<td>{$row['Other']}</td>\n";
}
    echo "<td align=right>{$row['Num']}</td>\n";
    echo "<td>{$row['Street']}</td>\n";

if ($row['Phone'] == "") {
    echo "<td>-</td>\n";
} else {
    echo "<td>{$row['Phone']}</td>\n";
}

if ($row['Email'] == "") {
    echo "<td>-</td>\n";
} elseif  ($row['Email'] == "-") {
    echo "<td>-</td>\n";
} else {
    echo "<td><a href=\"mailto:";, $row['Email'], "\">", $row['Email'],
"</a></td>";
}


    echo "</tr>\n";
  }
echo "</table>\n";

?>
</body>
</html>
====================

Thanks.


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Most low income households are not online. Help bridge the digital divide today!
http://us.click.yahoo.com/cd_AJB/QnQLAA/TtwFAA/CefplB/TM
--------------------------------------------------------------------~-> 

The php_mysql group is dedicated to learn more about the PHP/MySQL web database 
possibilities through group learning.  
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php_mysql/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




Reply via email to