-
Notifications
You must be signed in to change notification settings - Fork 0
/
getProducts.cgi
43 lines (30 loc) · 916 Bytes
/
getProducts.cgi
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/perl
# Sample perl cgi script. This script prints a list of the
# products in the opatija proj4.products table.
# For use with AJAX
# Code by Alan Riggins, Fall 2017
#
# For use with ajax only
#
use DBI;
my $host = "opatija.sdsu.edu";
my $port = "3306";
my $database = "proj4";
my $username = "jadrn028";
my $password = "storm";
my $database_source = "dbi:mysql:$database:$host:$port";
my $dbh = DBI->connect($database_source, $username, $password)
or die 'Cannot connect to db';
my $sth = $dbh->prepare("SELECT sku, category, title, short_description, long_description, cost, retail FROM products order by category");
$sth->execute();
$str = "";
while(my @row=$sth->fetchrow_array()) {
foreach $item (@row) {
$str .= $item."|";
}
$str .= ";";
}
print "Content-type: text/html\n\n";
$sth->finish();
$dbh->disconnect();
print $str;