| JacKDynne 2004-08-18, 3:57 pm |
| TIA to anyone that can help me; I have a little problem and it goes
like this:
I have a php/mysql app that captures telephone calls via user entry,
all works fine except for this - when users check to see if the
caller has called before there is a query that lists previous callers
by using this: --------
query = mysql_query("select `FirstName` , `LastName`
from tracker ORDER BY `FirstName`") or
die(mysql_error());
--------
which when run directly against the db in mysql returns everything
fine but when returned to the web page that calls it in php will not
list those with the same last name or first name, depending on how I
structure the query.
Here are the relevant pieces of code (in the order that it's
called):
viewclient.php
--------
<?
session_start();
header("Cache-control: private");
if (_SESSION["loggedin"] != 1)
{
echo "Please login before trying to access this script.";
exit();
}
require("include/config.php");
include("templates/header.php");
connection = mysql_connect (host, user,
pass) or die(mysql_error());
mysql_select_db (db) or die
(mysql_error());
query = mysql_query("select `FirstName` , `LastName`
from tracker ORDER BY `FirstName`") or
die(mysql_error());
echo "<form name='frmClient' method='post'
action='clientid.php'>";
echo "<table><tr><td
class='formleft'>Please select a
client:</td>";
echo "<td class='formright'><select
name='client'>";
while (line = mysql_fetch_row(query))
{
if (prev != line[0] &&
prev2 != line[1])
{
_line[0] =
str_replace(" ","",line[0]);
_echo "<option>" . line[0] . "
" .
line[1] . "</option>";
}
prev = line[0];
prev2 = line[1];
}
echo
"</select></td></tr><tr><td
class='formleft'> </td><td
class='formright'>";
echo "<input type='submit' /> <input
type='reset'
/></td></tr></table>";
include("templates/resultsfoot.php");
--------
clientid.php:
--------
<?
session_start();
header("Cache-control:
private");
if (_SESSION["loggedin"] != 1)
{
echo "Please login before
trying to access this script.";
exit();
}
require("include/config.php");
include("templates/header.php");
connection = mysql_connect (host,
user,
pass) or die(mysql_error());
mysql_select_db (db) or die
(mysql_error());
names = explode(" ",client);
query =
mysql_query("select `index` , `Screening` from
tracker WHERE `FirstName` =
'names[0]' AND
_`LastName` = 'names[1]' ORDER BY
`index`") or
die(mysql_error());
echo "<form name='frmClient' method='post'
action='reports/client.php'>";
echo "<table><tr><td
class='formleft'>Please select a call
number:</td>";
echo "<td
class='formright'><select
name='callnumber'>";
while (line =
mysql_fetch_row(query))
{
if (prev != line[0])
{
_line[0] =
str_replace(" ","",line[0]);
_echo "<option>" . line[0] . " Date
entered: " . line[1] .
"</option>";
}
prev = line[0];
}
echo
"</select></td></tr><tr><td
class='formleft'> </td><td
class='formright'>";
echo "<input type='submit' /> <input
type='reset'
/></td></tr></table>";
include("templates/resultsfoot.php");
?>
--------
client.php:
--------
<?
ob_start("ob_gzhandler");
session_start();
header("Cache-control: private");
if (_SESSION["loggedin"] != 1)
{
echo
"Please login before trying to access this script.";
exit();
}
require("../include/config.php");
echo "<html style='overflow-x:
hide'> |