[thelist] Mysql - wont read first entry?

Adrian Fischer adrian at logo-logic.com
Tue Oct 31 03:58:29 CST 2000


Hi Gang,

Thanks for your thoughts on the meta tag thing.  Wasn't planning on copying
et al but just wanted to check for different ideas.

Now to the next problem.  I have a mysql db that I cant seem to get the
first bit of data out of.  I enter it in the usual form method and it appear
in the  table but when I got to search and display that info it wont
display.  When I enter a second bit of data under the same column headings
and search on the same criteria ...the second  bit added displays.  I'm
thinking that it has something to do with the "while" and "foreach"
loops...but then again I've been doing dbases since the middle of last month
;-)

I  could  always just enter a blank field in each category (a search
criteria column) but then I think that would be cheating (or is that how it
is done).  If there is something I'm missing I would like to know.

Here is the call to the db for brevity I cut the top and bottom off.  They
were just the html stuff that displayed the info.

<snip>html stuff</snip>
$db_query = "SELECT
docId,docCat,docBusName,docAddress,docBusPhone,docDesc1,docDesc2,docDesc3,do
cState,docRegion,docSuburb,docHits FROM tblDockets WHERE docCat = '" .
sqlEncode($form{'CATEGORY'}) . "' AND docState='" .
sqlEncode($form{'STATE'}) . "'  ORDER BY docSuburb";
my $db = &dbconnect;
my $dbh=$db->prepare($db_query);
$dbh->execute();
death("We didn't find anything that meets that search!") unless
($docid,$category) = $dbh->fetchrow_array();
while
(($docid,$category,$busname,$address,$phone,$desc1,$desc2,$desc3,$state,$reg
ion,$suburb,$hits) = $dbh->fetchrow_array()) {
@{$tempitemhash{$docid}} =
($docid,$category,$busname,$address,$phone,$desc1,$desc2,$desc3,$state,$regi
on,$suburb,$hits);
push (@itemorder, $docid);
 }
foreach $docid (@itemorder) {
($docid,$category,$busname,$address,$phone,$desc1,$desc2,$desc3,$state,$regi
on,$suburb,$hits) = @{$tempitemhash{$docid}};
<snip>html stuff</snip>
&dbdisconnect($db);

I have come to realise over the last couple of years that compromises have t
o be made all the time with web development but surely this isn't one of
them.

Oh...and one other thing.  The other week we talked about having the column
(field) name in the SELECT and also in the WHERE as being redundant.  What
if I want the information in the SELECT to be displayed as well as being
part of the search criteria? If its just in the WHERE and not in the SELECT
can I then display it anyway?

Maybe I should take up knitting instead...(no offence to the knitters out
there)



Adrian Fischer
Albany Creek
Queensland 4035
Australia





More information about the thelist mailing list