jck has asked for the wisdom of the Perl Monks concerning the following question:
and then the following loop to match the requested UID with the results of the query, and identify the previous and next records:my $sql = "SELECT UID FROM news";
so, if i submit the value 2 as 'requestID', the results for $prevID is correctly listed as 1, $currID is undefined, and $nextID gets assigned as 2. this is what it looks like:while (my $newUID = $sth->fetchrow) { if ($in{'requestID'} == $newUID) { $currID = $newUID; } else { $prevID = $newUID; } ... #there's a counter to generate one more loop after the currID is f +ound, to capture "nextID" $nextID = $newUID; } print p(["Previous = |$prevID|","Current = |$currID|","Next = |$nextID +|"]);
0 #this is a counter value to escape the while loop after finding the +value of $nextID Previous = |1| Current = || Next = || 1 Previous = |1| Current = || Next = |2|
it seems to me that the condition ($in{'requestID'} == $newUID) is not getting evaluated correctly, and i'm wondering if one of the other value is not recognized as an integer? is that the problem? how do i fix it? the database file is MySQL, and the UID field is defined as an integer field.
TIA, janaki
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: datatype from SQL
by VSarkiss (Monsignor) on Jun 23, 2006 at 17:23 UTC | |
by jck (Scribe) on Jun 23, 2006 at 17:36 UTC | |
by VSarkiss (Monsignor) on Jun 23, 2006 at 17:42 UTC | |
by derby (Abbot) on Jun 23, 2006 at 17:45 UTC | |
by jck (Scribe) on Jun 23, 2006 at 17:29 UTC | |
by jck (Scribe) on Jun 23, 2006 at 17:32 UTC | |
|
Re: datatype from SQL
by jck (Scribe) on Jun 23, 2006 at 17:49 UTC |