home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2960
Discussions: 188,378, Posts: 2,243,454, Members: 232,606
Old November 5th, 2002, 12:45 PM   Digg it!   #1 (permalink)
Member
 
tenor_david's Avatar
 
Join Date: Nov 2001
Location: Bloomington IN
Posts: 219
Returing Records From SQL

Hey folks.....I am writing a simple application with Perl and Oracle where the user can input a table name, and it will return the first 10 rows.

How can I expand this so that there is a 'next' button or something that will display the next 10 rows, and then the next, etc. etc.?

Here is what I have so far [code in blue retrieves 1st 10 rows]

#!/bin/perl

require './db_lib.pl';
require './cgi-lib.pl';

# read and parse the input variables
&ReadParse;


###################
# Make a connection
###################
$db = &DBlogin;

#################
# set the command
#################
$db_command = "select * from " . $in{'table'};

###################
# execute the query
###################
@data = &getdata($db, $db_command);

#################
# get the results
#################
if ($#data < 0) {
$result = "Could not find " . $in{'table'} . " in the database.";
}

while ($counter <= $#data) {
$result = "<table border>";
for ($i = 0; $i <= 9; $i++) {
$result = "$result<tr>";
for ($j = 0; $j <= $width; $j++) {
$result = "$result<td>$data[$i][$j]</td>";
}
$result = "$result</tr>";
}
$result = "$result</table>";
$counter++;
}


use CGI;
$mycgi = CGI->new;
print $mycgi->header;
print << "end";
<html>
<body>
<left>
<hr>
The query executed was:$db_command<br><br>
The result:<br>
$result

<hr>
<form action="db_form_10.pl" method=post>
<input type="submit" name="submit" value="Submit"><br><br>
Table <input type="text" name="table" value="" size="20">
</form>
</left>
</body>
</html>
end


Thanks for any input.

tenor_david is offline   Reply With Quote
Old November 5th, 2002, 12:51 PM     #2 (permalink)
Kawaru wa yo!
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 16,132
Blog Entries: 7
Arrr, can you make arrays in Perl? If so, I would save all of the records to an array, then write some next/previous buttons to navigate through the array. I don't know Perl, so I can't help with the code.

Whir is online now   Reply With Quote
Old November 5th, 2002, 12:56 PM     #3 (permalink)
Member
 
tenor_david's Avatar
 
Join Date: Nov 2001
Location: Bloomington IN
Posts: 219
Yeah, the records are actuallystored in an array, one step above the blue highlighted code.

I will fiddle around w/ that idea and see what I can come up with. Thanks!

tenor_david is offline   Reply With Quote
Old November 5th, 2002, 01:07 PM     #4 (permalink)
Kawaru wa yo!
 
Whir's Avatar
 
Join Date: Oct 2001
Location: Kingsford, MI
Posts: 16,132
Blog Entries: 7
Oops! Sorry, didn't even see that. I'm clueless on the data type prefixes in Perl.

All you really need then is a variable to keep track of which set you are currently displaying. So if it's 0 and they hit the next button, it jumps the variable up +10 and then iterates through the array displaying the next ten (10 - 19). I don't know if you can make global variables in Perl. If not, you would want to write some sort of search maybe and grab the data in the first field and search for it, then set your place holder variable that way?
Whir is online now   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2883)
The United States Debt (20)
Looks like Burris will get his Sena.. (8)
I think I just killed my computer w.. (24)
Upgrading RAM (5)
Folderchat Weekday thread (439)
Antec 300 bulk purchase? (11)
Worth the upgrade?? (14)
Titan quest and Immortal Throne, an.. (17)
Recent Discussions
New Build ( Finally ) (1)
dual monitors wont boot (0)
Folderchat Weekday thread (439)
MSN Hotmail Down??? (7)
Help with an Ati Radeon HD 4850.. (23)
Laptop waking up itself (0)
CPU wont boot (3)
Best digital camera for under 2.. (13)
Building first computer, will t.. (2)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 08:23 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28