Page 2 of 2
Posted: Thu Aug 25, 2005 10:10 pm
by feyd
sounds like mysql_num_rows() returned zero.
Posted: Thu Aug 25, 2005 10:15 pm
by michlcamp
must be, but don't know why...several rows in each table
Posted: Thu Aug 25, 2005 10:16 pm
by feyd
Could you post an export of the two tables' structures?
Posted: Thu Aug 25, 2005 10:19 pm
by michlcamp
fixed it - it was here:
$query= "select * from `customers`, `orders2` where `orders2`.realname = '$realname' and `customers`.realname = `orders2`.`realname`";
changed to:
$query= "select * from `customers`, `orders2` where `orders2`.realname = `customers`.realname and `customers`.realname = `orders2`.`realname`";
Now I just have to config the HTML output...
boy, thanks a million!
this is a fantastic resource for someone trying to learn the how-to's
LAST QUESTION
Posted: Thu Aug 25, 2005 10:24 pm
by michlcamp
Now, what's the best way to search for single orders?
whole new can of worms?
Posted: Thu Aug 25, 2005 10:37 pm
by feyd
it's actually not all that bad.
This should be the same query you just wrote, in a different look
Code: Select all
SELECT
*
FROM
`customers`
INNER JOIN
`orders2`
ON
(
`customers`.`realname` = `orders2`.`realname`
)
Using that,
Code: Select all
SELECT
*
FROM
`customers`
INNER JOIN
`orders2`
ON
(
`customers`.`realname` = `orders2`.`realname`
)
WHERE
`specificField` = 'some value'
is a natural extension.
Posted: Thu Aug 25, 2005 10:43 pm
by michlcamp
many thanks...I'll give that a try in a minute...right now trying to figure out how to post only those fields that have an entry - or at least to hide the zero values
Thanks to all
Posted: Fri Aug 26, 2005 7:38 am
by michlcamp
all is well
many thanks to all who helped me here.
mc
strange results
Posted: Fri Aug 26, 2005 10:24 am
by michlcamp
one thing that's wierd...
when I query for a report, I get duplicates of orders when they're by the same customer - wondering how to configure it so I only get one result for each order...
query I'm using :
Code: Select all
echo "<a href=\"order_admin.php\">Admin</a><br>";
$realname2 = $_POST["realname"];
include("host.php");
$dbh=mysql_connect ($host, $user, $password);
$link = $dbh;
@mysql_select_db($dbname) or die( "Unable to select database");
$sql = "SELECT * FROM `customers`INNER JOIN `orders2` ON (`customers`.`realname` = `orders2`.`realname`) WHERE `customers`.`realname`= '$realname2' ORDER BY orders2.date desc";
$query=$sql;
$result = mysql_query($query) or die(mysql_error());
if (is_resource($result)){
if (mysql_num_rows($result)){
etc
Posted: Fri Aug 26, 2005 10:26 am
by patrikG