Welcome to WebmasterWorld Guest from 107.20.20.39

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

perl script to display user bids

im trying to display info that the user has put in sell page

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

5+ Year Member



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
2:29 am on Apr 23, 2007 (gmt 0)

5+ Year Member



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.
8:34 pm on Apr 24, 2007 (gmt 0)

5+ Year Member



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;

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

5+ Year Member



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.

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

5+ Year Member



thanks man!