homepage Welcome to WebmasterWorld Guest from 54.196.159.11
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
perl script to display user bids
im trying to display info that the user has put in sell page
harrinju




msg:3318397
 8:48 pm on Apr 22, 2007 (gmt 0)

hey guys, i have a project thats similar to ebay, i have it so at my sell page the seller puts in their products and when the form button is pressed that info goes to my database(sell table). i want to display that info(every time the seller puts in a new product) on another html page so the seller has a list of his/her product info. i was thinking of putting the data in an array and then creating a loop and displaying it that way, but how do i know how many rows to put. In other words, how do i get the number of rows so it will keep displaying(onto another page) what the sellers are puting in.
p.s. all i need is the logic behind displaying data onto a page every time the user clicks on a form button. thankx

 

perl_diver




msg:3318566
 2:29 am on Apr 23, 2007 (gmt 0)

your question is broad and vague. If the data is in a database you query the database and collect whatever data it is you are wanting to display then output that data however is necessary, in a browser that would be with html code to format the display.

harrinju




msg:3320524
 8:34 pm on Apr 24, 2007 (gmt 0)

It's not displaying evrything i want, it's only displaying the last row of the table, not the whole table. How do i get it to display the contents of the whole table. i am using fetch_row()

#!/usr/bin/perl
use CGI;
use CGI qw/ :standard/;
use CGI::Carp qw(fatalsToBrowser);

#these are the default paths to search for files
push(@INC,"/.../.../cgi-bin/");

$category = "";
$brand = "";
$price = "";
$location = "";
$description = "";
$PIC_URL1 = "";
$PIC_URL2 = "";
$PIC_URL3 = "";

use DBD::mysql;
use DBI;

$dbh=DBI->connect("DBI:mysql:whatever:whatever:whatever","whatever",'whatev;
$sth=$dbh->prepare("SELECT * FROM sell");

$sth->execute();
#$results = $sth->rows;
#$i=0;
while(@ref = $sth->fetchrow_array())
{
$category = "$ref[0]";
$brand = "$ref[1]";
$price = "$ref[2]";
$location = "$ref[3]";
$description = "$ref[4]";
$PIC_URL1 = "$ref[5]";
$PIC_URL2 = "$ref[6]";
$PIC_URL3 = "$ref[7]";
#$i++;
}
$sth->finish();
$dbh->disconnect();

print "Content-type: text/html\n\n";

print<<"eot";
<HTML>
<HEAD><TITLE>Kbay Buy Page</TITLE></HEAD>
<BODY BGCOLOR=WHITE TEXT=BLUE>
<font size = 5>
<P>
$category $brand $price $location $description $PIC_URL1 $PIC_URL2 $PIC_URL3
<P>
</BODY>
</HTML>
eot
exit;

perl_diver




msg:3320578
 9:36 pm on Apr 24, 2007 (gmt 0)

thats because you just keep loop throug the data until the last row then print somethig. Something like this:


my $output = '<table>';
while(@ref = $sth->fetchrow_array())
{
$output .= '<tr><td>' . join(' ',@ref) . '</td></tr>';
}
$output .= '</table>';
$sth->finish();
$dbh->disconnect();
print "Content-type: text/html\n\n";
print qq~
<HTML>
<HEAD><TITLE>Kbay Buy Page</TITLE></HEAD>
<BODY BGCOLOR=WHITE TEXT=BLUE>
$output
</BODY>
</HTML>
~;
exit;

you can fiddle with the html display to get it how you want it.

harrinju




msg:3321521
 6:11 pm on Apr 25, 2007 (gmt 0)

thanks man!

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved