Gossamer Forum
Home : Products : DBMan : Installation :

links with NULL

Quote Reply
links with NULL
Hi everyone!

I have a form that includes a field (Store_name) that use HREF syntax. The Store_name field links to the URL. It works great as long as a URL other wise if there is a null value it attempts to use "Null" as the URL.

How can I tell it not to do this?
Quote Reply
Re: links with NULL In reply to
if ($rec{'Store_Name'}) {
print qq|<a href="$rec{'Store_Name'}|;
}



------------------
JPD
Quote Reply
Re: links with NULL In reply to
That did not work ofr me now I get an error when running the program. Here is the code from the html.pl Let me know if there is anything that you see. Thanks

my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=1 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=1';

print qq|
<TABLE WIDTH="80%" CELLPADDING=0 CELLSPACING=0>

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color></FONT></TD>
<TD> <$font>|;
if ($rec{'URL'}) {print qq|<a href="$rec{'URL'}>$rec{'Store_Name'}|;
else {print qq|$rec{'Address'}|;}}
print qq|</A></Font></TD></TR>

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color></FONT></TD>
<TD> <$font>$rec{'Address'}</Font></TD></TR>

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color></FONT></TD>
<TD> <$font>$rec{'City'}</Font> <$font>$rec{'State'} <$font>$rec{'Zipcode'}</Font></Fo nt></TD></TR>

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color></FONT></TD>
<TD> <$font>$rec{'Phone'}</Font></TD></TR>
</TABLE>
|;
}
Quote Reply
Re: links with NULL In reply to
Here's your problem:

if ($rec{'URL'}) {print qq|<a href="$rec{'URL'}>$rec{'Store_Name'}|;
else {print qq|$rec{'Address'}|;}}

should be

if ($rec{'URL'}) {
print qq|<a href="$rec{'URL'}>$rec{'Store_Name'}|;
}
else {print qq|$rec{'Address'}|;}

(I changed the spacing so I could see it better.)

I think this should work for you.

This may be what you want, but you have the $rec{'Address'} twice if the record doesn't have a URL.

------------------
JPD


[This message has been edited by JPDeni (edited January 15, 1999).]
Quote Reply
Re: links with NULL In reply to
It's kind of hard to tell what's going on, but it looks like you forgot a bracket after your if conditional. Try this and see if it works for you:

Code:
if ($rec{'URL'}) {
print qq|<a href="$rec{'URL'}>$rec{'Store_Name'}</a>|;
} else {
print qq|$rec{'Address'}|;
}
Quote Reply
Re: links with NULL In reply to
Ok.. so I tried this, and noticed that I made a mistake when I gave the code. I'm still have a problem because it will not show the 'Stone_name' field at all.

I have a #ERROR HERE in the code so you can see it. here is the address where you can try it:

http://www.alldata.com/pro/free/smartshops_new.html

Please help
Quote Reply
Re: links with NULL In reply to
#
# ----------------------
# DBMan
# ----------------------
# Database Administrator
#
# File: html.pl
# Description: This file contains all the HTML that the program generates.
# Author: Alex Krohn
# Email: alex@gossamer-threads.com
# Web: http://www.gossamer-threads.com/
# Version: 2.04
#
# COPYRIGHT NOTICE:
#
# Copyright 1997 Gossamer Threads Inc. All Rights Reserved.
#
# This program is being distributed as shareware. It may be used and
# modified free of charge for personal, academic, government or non-profit
# use, so long as this copyright notice and the header above remain intact.
# Any commercial use should be registered. Please also send me an email,
# and let me know where you are using this script. By using this program
# you agree to indemnify Gossamer Threads Inc. from any liability.
#
# Selling the code for this program without prior written consent is
# expressly forbidden. Obtain permission before redistributing this
# program over the Internet or in any other medium. In all cases
# copyright and header must remain intact.
#
# Please check the README file for full details on registration.
# =====================================================================

##########################################################
## HTML Globals ##
##########################################################
# Put any globals you like in here for your html pages.
$html_title = 'ALLDATA Smart Shops';

##########################################################
## Record Layout ##
##########################################################

sub html_record_form {
# --------------------------------------------------------
# The form fields that will be displayed each time a record is
# edited (including searching). You don't want to put the
# <FORM> and </FORM tags, merely the <INPUT> tags for each field.
# The values to be displayed are in %rec and should be incorporated
# into your form. You can use &build_select_field, &build_checkbox_field
# and &build_radio_field to generate the respective input boxes. Text and
# Textarea inputs can be inserted as is. If you turn on form auto
# generation, the program will build the forms for you (all though they may
# not be as nice). See the README for more info.

my (%rec) = @_;
($db_auto_generate and print &build_html_record_form(%rec) and return);

my $font = 'Font face="Arial" Size=1';

print qq|
<TABLE WIDTH="476" CELLPADDING=0 CELLSPACING=0>
<TR><TD ALIGN="Left" VALIGN="TOP" WIDTH="50%"><Font face="Arial" Size=2>Your City: </TD>
<TD VALIGN="TOP" WIDTH="50%"> <INPUT TYPE="TEXT" NAME="City" VALUE="$rec{'City'}" MAXLENGTH="256"></TD></TR>

<TR><TD ALIGN="Left" VALIGN="TOP"><Font face="Arial" Size=2>Your State (2 letter abbrev.): </FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="State" VALUE="$rec{'State'}" SIZE="2" MAXLENGTH="2"></TD></TR>

<TR><TD ALIGN="Left" VALIGN="TOP"><Font face="Arial" Size=2>Your Zip Code (optional): </FONT></TD>
<TD VALIGN="TOP"> <INPUT TYPE="TEXT" NAME="Zipcode" VALUE="$rec{'Zipcode'}" SIZE="5" MAXLENGTH="10"></TD></TR>

</TABLE>
|;
}

sub html_record {
# --------------------------------------------------------
# How a record will be displayed. This is used primarily in
# returning search results and how it is formatted. The record to
# be displayed will be in the %rec hash.

my (%rec) = @_; # Load any defaults to put in the VALUE field.
($db_auto_generate and print &build_html_record(%rec) and return);

my $font_color = 'Font face="Verdana, Arial, Helvetica" Size=1 Color=#003399';
my $font = 'Font face="Verdana, Arial, Helvetica" Size=1';

print qq|
<TABLE WIDTH="80%" CELLPADDING=0 CELLSPACING=0>

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color></FONT></TD>
<TD> <$font>|;
#ERROR IS HERE

if ($rec{'URL'}) {
print qq|<a href="$rec{'URL'}>$rec{'Store_Name'}|;
}
else {
print qq|$rec{'Store_Name'}|;
}
print qq|</A></Font></TD></TR>

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color></FONT></TD>
<TD> <$font>$rec{'Address'}</Font></TD></TR>

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color></FONT></TD>
<TD> <$font>$rec{'City'}</Font> <$font>$rec{'State'} <$font>$rec{'Zipcode'}</Font></Fo nt></TD></TR>

<TR><TD ALIGN="Right" VALIGN="TOP"><$font_color></FONT></TD>
<TD> <$font>$rec{'Phone'}</Font></TD></TR>
</TABLE>
|;
}

##########################################################
## Home Page ##
##########################################################

sub html_home {
# --------------------------------------------------------
# The database manager home page.

&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Main Menu.</title>
</head>

<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Main Menu</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
Main Menu
</b></font></center><br>
<font face="verdana,arial,helvetica" size="1"><b>
Permissions: |;
print " View " if ($per_view);
print " Add " if ($per_add);
print " Delete " if ($per_del);
print " Modify " if ($per_mod);
print " Admin " if ($per_admin);
print " None " if (!($per_view &#0124; &#0124; $per_add &#0124; &#0124; $per_del &#0124; &#0124; per_mod));
print qq|</b></font>
<P><$font>
This database has been set up so any user can view any other users information, but you can
only modify and delete your own records. If you have admin access, you can of course do anything
you like.<br><br>
<em>Enjoy!</em> and let me <a href="mailto:alex\@gossamer-threads.com">know</a> if you have any comments!
</font>

</p>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</body>
</html>
|;
}

sub html_footer {
# --------------------------------------------------------
# Print the menu and the footer and logo. It would be nice if you left
# the logo in. Wink
#
# We only print options that the user have permissions for.
#

my $font = 'Font face="Verdana, Arial, Helvetica" Size=2';

print qq!<P align=center><$font>!;
print qq!| <A HREF="$db_script_link_url">Home</A> !;
print qq!| <A HREF="$db_script_link_url&add_form=1">Add</A> ! if ($per_add);
print qq!| <A HREF="$db_script_link_url&view_search=1">View</A> ! if ($per_view);
print qq!| <A HREF="$db_script_link_url&delete_search=1">Delete</A> ! if ($per_del);
print qq!| <A HREF="$db_script_link_url&modify_search=1">Modify</A> ! if ($per_mod);
print qq!| <A HREF="$db_script_link_url&view_records=1&$db_key=*">List All</A> ! if ($per_view);
print qq!| <A HREF="$db_script_link_url&admin_display=1">Admin</A> ! if ($per_admin);
print qq!| <A HREF="$db_script_link_url&logoff=1">Log Off</A> |!;
print qq!</font></p>!;





# Print the Footer.
# print qq!
# <table border=0 width=100%>
# <tr><td align=left><$font>Copyright 1998 <A HREF="http://www.gossamer-threads.com">Gossamer Threads Inc.</A></font></td>
# <td align=right><a href="http://www.gossamer-threads.com/scripts/dbman/"><img src="http://www.gossamer-threads.com/images/powered.gif" border=0 width=100 height=31 alt="Database Powered by Gossamer Threads Inc."></a></td></tr>
# </table>
# !;
}

sub html_search_options {
# --------------------------------------------------------
# Search options to be displayed at the bottom of search forms.
#
print qq~
<P>
<STRONG>Search Options:</STRONG> <br>
<INPUT TYPE="CHECKBOX" NAME="ma"> Match Any
<INPUT TYPE="CHECKBOX" NAME="cs"> Match Case
<INPUT TYPE="CHECKBOX" NAME="ww"> Whole Words
<INPUT TYPE="CHECKBOX" NAME="re"> Reg. Expression<BR>
<INPUT TYPE="TEXT" NAME="keyword" SIZE=15 MAXLENGTH=255> Keyword Search <FONT SIZE=-1> (will match against all fields)</FONT><BR>
<INPUT TYPE="TEXT" NAME="mh" VALUE="$db_max_hits" SIZE=3 MAXLENGTH=3> Max. Returned Hits<BR>
Sort By:
<SELECT NAME="sb">
<OPTION>---
~; for (my $i =0; $i <= $#db_cols; $i++) { print qq~<OPTION VALUE="$i">$db_cols[$i]</OPTION>\n~ if ($db_form_len{$db_cols[$i]} >= 0); } print qq~
</SELECT>
Sort Order:
<SELECT NAME="so">
<OPTION VALUE="ascend">Ascending
<OPTION VALUE="descend">Descending
</SELECT><br><br>
<strong>Search Tips:</strong><br>
- use '*' to match everything in a field)<BR>
- put a '>' or '<' at the beginning to to do range searches.<BR>
~;
}

##########################################################
## Adding ##
##########################################################

sub html_add_form {
# --------------------------------------------------------
# The add form page where the user fills out all the details
# on the new record he would like to add. You should use
# &html_record_form to print out the form as it makes
# updating much easier. Feel free to edit &get_defaults
# to change the default values.

&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Add a New Record.</title>
</head>

<body bgcolor="#DDDDDD">
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Add a New Record</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
Add a New Record
</b></font></center><br>
<$font>
|; &html_record_form (&get_defaults); print qq|
</font></p>
<p><center> <INPUT TYPE="SUBMIT" NAME="add_record" VALUE="Add Record"> <INPUT TYPE="RESET" VALUE="Reset Form"></center></p>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</form>
</body>
</html>
|;
}

sub html_add_success {
# --------------------------------------------------------
# The page that is returned upon a successful addition to
# the database. You should use &get_record and &html_record
# to verify that the record was inserted properly and to make
# updating easier.

&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Record Added.</title>
</head>

<body bgcolor="#DDDDDD">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Record Added</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
Record Added
</b></font></center><br>
<$font>
<P><Font face="Verdana, Arial, Helvetica" Size=2>The following record was successfully added to the database:</FONT>
|; &html_record(&get_record($in{$db_key})); print qq|
</font></p>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</body>
</html>
|;
}

sub html_add_failure {
# --------------------------------------------------------
# The page that is returned if the addition failed. An error message
# is passed in explaining what happened in $message and the form is
# reprinted out saving the input (by passing in %in to html_record_form).

my ($message) = $_[0];

&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Error! Unable to Add Record.</title>
</head>

<body bgcolor="#DDDDDD">
<form action="$db_script_url" method="POST">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Error: Unable to Add Record</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
Error: <font color=red>Unable to Add Record</font>
</b></font></center><br>
<$font>
There were problems with the following fields: <FONT COLOR="red"><B>$message</B></FONT>
<P>Please fix any errors and submit the record again.</p></font>
|; &html_record_form (%in); print qq|
</font></p>
<p><center> <INPUT TYPE="SUBMIT" NAME="add_record" VALUE="Add Record"> <INPUT TYPE="RESET" VALUE="Reset Form"></center></p>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</form>
</body>
</html>
|;
}

##########################################################
## Viewing ##
##########################################################

sub html_view_search {
# --------------------------------------------------------
# This page is displayed when a user requests to search the
# database for viewing.
# Note: all searches must use GET method.
#
&html_print_headers;
print qq|
<html>
<head>
<title>$html_title: Search the Database.</title>
</head>

<body bgcolor="#DDDDDD">
<form action="$db_script_url" method="GET">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<center>
<table border=1 bgcolor="#FFFFFF" cellpadding=5 cellspacing=3 width=500 align=center valign=top>
<tr><td colspan=2 bgcolor="navy">
<FONT FACE="MS Sans Serif, arial,helvetica" size=1 COLOR="#FFFFFF">
<b>$html_title: Search the Database</b>
</td></tr>
<tr><td>
<p><center><$font_title><b>
Search the Database
</b></font></center><br>
<$font>
|; &html_record_form(); print qq|
|; &html_search_options; print qq|
</font></p>
<p><center> <INPUT TYPE="SUBMIT" NAME="view_records" VALUE="View Records"> <INPUT TYPE="RESET" VALUE="Reset Form"></center></p>
|; &html_footer; print qq|
</td></tr>
</table>
</center>
</form>
</body>
</html>
|;
}

sub html_view_success {
# --------------------------------------------------------
# This page displays the results of a successful search.
# You can use the following variables when displaying your
# results:
#
# $numhits - the number of hits in this batch of results.
# $maxhits - the max number of hits displayed.
# $db_total_hits - the total number of hits.
# $db_next_hits - html for displaying the next set of results.
#

my (@hits) = @_;
my ($numhits) = ($#hits+1) / ($#db_cols+1);
my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits);

&html_print_headers;
print qq|
<!-BEGIN HEADER -->
<html>
<head>
<title>Find an ALLDATA equipped shop near me!</title>
</head>

<body topmargin="0" leftmargin="0" background="http://www.alldata.com/pro/images/background--drkblue.GIF" bgcolor="#FFFFFF" link="#4A58FD">
<div align="left">

<table border="0" cellpadding="3" width="610">
<tr>
<td width="134"><table border="0" width="115" height="50" cellspacing="0" cellpadding="0">
<tr>
<td width="21" height="44"><a href="http://www.alldata.com/pro/index.htm"><img src="http://www.alldata.com/pro/images/home.GIF" alt="Return to the ALLDATA Homepage" align="middle" border="0" WIDTH="24" HEIGHT="55"></a></td>
<td width="82" height="44"><p align="center"><a href="http://www.alldata.com/pro/customerservices/training/aisindex.htm"><img src="http://www.alldata.com/pro/images/patchpro2sharp.GIF" alt="Become a Certified ALLDATA Automotive Information Specialist!" align="middle" border="0" WIDTH="47" HEIGHT="55"></a></td>
</tr>
</table>
</td>
<td width="476" align="center"><img src="http://www.alldata.com/pro/images/logo.gif" alt="ALLDATA Corporation" border="0" align="center" WIDTH="360" HEIGHT="48"></td>
</tr>
<tr>
<td valign="top" align="left" width="134"><font size="2" color="#FFFFFF" face="Arial"><!--webbot bot="HTMLMarkup" StartSpan --> <p>

<b><a href="http://www.alldata.com/pro/recallsbulletins/index.htm"><font face="Arial" size="2" color="#FAFAFA">Recalls/Bulletins</font></a></b>
<b><a href="http://www.alldata.com/pro/products/index.htm"><font size="2" color="#FAFAFA" face="Arial">Product Info</font></a></b><br>
<b><a href="http://www.alldata.com/pro/free/index.htm"><font size="2" color="#FFFF00" face="Arial">Free!</font></a></b>
<br>
<font color="#FAFAFA">&#149; <b><a href="contact.htm"><font face="Arial" size="1" color="#FAFAFA">Demo Disc/</font></a></b><br>
<font color="#FAFAFA"> <b><a href="contact.htm"><font face="Arial" size="1" color="#FAFAFA">More Info!</font></a><br>

<font color="#FFFF00">&#149; <b><font face="Arial" size="1" color="#FFFF00">Smart Shops</font><br>

<br>
<b><a href="http://www.alldata.com/pro/inside/index.htm"><font size="2" color="#FAFAFA" face="Arial">Inside ALLDATA</font></a></b><br>
<b><a href="http://www.alldata.com/pro/whatsnew/index.htm"><font face="Arial" size="2" color="#FAFAFA">What's New!</font></a></b><br>
<b><a href="http://www.alldata.com/pro/customerservices/index.htm"><font size="2" color="#FAFAFA" face="Arial">Services</a></b><br>
<b><a href="http://www.alldata.com/pro/industry/index.htm"><font size="2" color="#FAFAFA" face="Arial">Industry</a></b><br>
<b><a href="http://www.alldata.com/pro/links/index.htm"><font size="2" color="#FAFAFA" face="Arial">Links</a></b><br>
</p>
<!--webbot BOT="HTMLMarkup" endspan --></font></td>
<td valign="top" align="left" width="476"><hr>
<font face="Arial" size-"1">
<b>$html_title: Search Results</b>
<p>
Your search returned <b>$db_total_hits</b> matches.</font><BR>
<!-END HEADER -->
|;

# Go through each hit and convert the array to hash and send to
# html_record for printing.
for (0 .. $numhits - 1) {
print "<P>";
&html_record (&array_to_hash($_, @hits));
}
if ($db_next_hits) {
print "<br><$font>Pages: $db_next_hits</font>";
}

print qq|
<p>
<table border=0 bgcolor="#DDDDDD" cellpadding=5 cellspacing=3 width=500 valign=top>|;

print qq|
</table>
</blockquote>
<!-BEGIN FOOTER --></td>
</tr>
<tr>
<td width="134"></td>
<td width="476"><hr>
<table border="0" width="468">
<tr>
<td width="74" align="center"><img src="http://www.alldata.com/pro/images/toolart-noback.JPG" width="79" height="56" alt="ALLDATA: The Ultimate Tool.JPG (6792 bytes)" border="0"></td>
<td width="56" align="center" valign="middle"><a href="http://www.alldata.com/pro/index.htm"><font face="Arial" size="2" color="#000080"><strong>HOME</strong></font></a></td>
<td width="171" align="center" valign="middle"><strong><a href="#top"><font face="Arial" size="2" color="#000080">TOP OF THE PAGE</font></a></strong></td>
<td width="76" align="center" valign="middle"><a href="http://www.alldata.com/pro/sitemap/sitemap.htm"><font face="Arial" size="2" color="#000080"><strong>SITE MAP</strong></font></a></td>
<td width="74" align="center"><img src="http://www.alldata.com/pro/images/toolart-noback.JPG" width="79" height="56" alt="ALLDATA: The Ultimate Tool.JPG (6792 bytes)" border="0"></td>
</tr>
</table>
<div align="center"><center><table border="0" cellspacing="0" width="465" bgcolor="#0F5A9F">
<tr>
<td align="center" face="Arial" size="1"><!--webbot bot="HTMLMarkup" StartSpan -->
<td align="center"><a href="http://www.alldata.com/pro/recallsbulletins/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">Recalls/Bulletins</font></strong></a></td>
<td align="center"><strong><font color="#FFFF00" face="Arial" size="2">&#149;</font><strong></td>
<td align="center"><a href="http://www.alldata.com/pro/products/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">Products</font></strong></a><strong></td>
<td align="center"><strong><font color="#FFFF00" face="Arial" size="2">&#149;</font><strong></td>
<td align="center"><a href="http://www.alldata.com/pro/free/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">Free!</font></strong></a></td>
<td align="center"><strong><font color="#FFFF00" face="Arial" size="2">&#149;</font><strong></td>
<td align="center"><a href="http://www.alldata.com/pro/inside/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">Inside ALLDATA</font><strong></a><strong></td>
<!--webbot BOT="HTMLMarkup" endspan --></td>
</tr>
</table>
</center></div><div align="center"><center><table border="0" cellspacing="0" width="465" bgcolor="#0F5A9F">
<tr>
<td align="center" face="Arial" size="1"><!--webbot bot="HTMLMarkup" StartSpan -->

<td align="center"><a href="http://www.alldata.com/pro/whatsnew/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">What's New!</font><strong></a><strong></td>
<td align="center"><strong><font color="#FFFF00" face="Arial" size="2">&#149;</font><strong></td>
<td align="center"><a href="http://www.alldata.com/pro/customerservices/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">Services</font><strong></a><strong></td>

<td align="center"><strong><font color="#FFFF00" face="Arial" size="2">&#149;</font><strong></td>
<td align="center"><a href="http://www.alldata.com/pro/industry/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">Industry</font><strong></a><strong></td>

<td align="center"><strong><font color="#FFFF00" face="Arial" size="2">&#149;</font><strong></td>
<td align="center"><a href="http://www.alldata.com/pro/links/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">Links</font><strong></a><strong></td>

<td align="center"><strong><font color="#FFFF00" face="Arial" size="2">&#149;</font></strong></td>
<td align="center"><a href="http://www.alldata.com/pro/inside/contact/contact.htm"><strong><font color="#FAFAFA" face="Arial" size="1">Contact Us</font><strong></a><!--webbot BOT="HTMLMarkup" endspan --></td>
</tr>
</table>
</center></div><p><CENTER><font face="Arial" size="1"> Copyright &copy; 1999 ALLDATA, All rights reserved. 800-829-8727</font></center></td>
</tr>
</table>
</div>
</body>
</html><!-END FOOTER -->
|;
}

sub html_view_failure {
# --------------------------------------------------------
# The search for viewing failed. The reason is stored in $message
# and a new search form is printed out.

my ($message) = $_[0];

&html_print_headers;
print qq|
<!-BEGIN HEADER -->
<html>
<head>
<title>Find an ALLDATA equipped shop near me!</title>
</head>

<body topmargin="0" leftmargin="0" background="http://www.alldata.com/pro/images/background--drkblue.GIF" bgcolor="#FFFFFF" link="#4A58FD">
<div align="left">

<table border="0" cellpadding="3" width="610">
<tr>
<td width="134"><table border="0" width="115" height="50" cellspacing="0" cellpadding="0">
<tr>
<td width="21" height="44"><a href="http://www.alldata.com/pro/index.htm"><img src="http://www.alldata.com/pro/images/home.GIF" alt="Return to the ALLDATA Homepage" align="middle" border="0" WIDTH="24" HEIGHT="55"></a></td>
<td width="82" height="44"><p align="center"><a href="http://www.alldata.com/pro/customerservices/training/aisindex.htm"><img src="http://www.alldata.com/pro/images/patchpro2sharp.GIF" alt="Become a Certified ALLDATA Automotive Information Specialist!" align="middle" border="0" WIDTH="47" HEIGHT="55"></a></td>
</tr>
</table>
</td>
<td width="476" align="center"><img src="http://www.alldata.com/pro/images/logo.gif" alt="ALLDATA Corporation" border="0" align="center" WIDTH="360" HEIGHT="48"></td>
</tr>
<tr>
<td valign="top" align="left" width="134"><font size="2" color="#FFFFFF" face="Arial"><!--webbot bot="HTMLMarkup" StartSpan --> <p>

<b><a href="http://www.alldata.com/pro/recallsbulletins/index.htm"><font face="Arial" size="2" color="#FAFAFA">Recalls/Bulletins</font></a></b>
<b><a href="http://www.alldata.com/pro/products/index.htm"><font size="2" color="#FAFAFA" face="Arial">Product Info</font></a></b><br>
<b><a href="http://www.alldata.com/pro/free/index.htm"><font size="2" color="#FFFF00" face="Arial">Free!</font></a></b>
<br>
<font color="#FAFAFA">&#149; <b><a href="contact.htm"><font face="Arial" size="1" color="#FAFAFA">Demo Disc/</font></a></b><br>
<font color="#FAFAFA"> <b><a href="contact.htm"><font face="Arial" size="1" color="#FAFAFA">More Info!</font></a><br>

<font color="#FFFF00">&#149; <b><font face="Arial" size="1" color="#FFFF00">Smart Shops</font><br>

<br>
<b><a href="http://www.alldata.com/pro/inside/index.htm"><font size="2" color="#FAFAFA" face="Arial">Inside ALLDATA</font></a></b><br>
<b><a href="http://www.alldata.com/pro/whatsnew/index.htm"><font face="Arial" size="2" color="#FAFAFA">What's New!</font></a></b><br>
<b><a href="http://www.alldata.com/pro/customerservices/index.htm"><font size="2" color="#FAFAFA" face="Arial">Services</a></b><br>
<b><a href="http://www.alldata.com/pro/industry/index.htm"><font size="2" color="#FAFAFA" face="Arial">Industry</a></b><br>
<b><a href="http://www.alldata.com/pro/links/index.htm"><font size="2" color="#FAFAFA" face="Arial">Links</a></b><br>
</p>
<!--webbot BOT="HTMLMarkup" endspan --></font></td>
<td valign="top" align="left" width="476"><hr>

<form action="$db_script_url" method="GET">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">
<center>

<p><center><$font_title><b>
Search Failed
</b></font></center><br>
<$font>
<P>There were problems with the search.<br><BR> Reason: <FONT COLOR="red"><B>$message</B></FONT>
<BR><BR>Please correct any errors and <BR>resubmit your SmartShop request again.</p>
|; &html_record_form(%in); print qq|
</font></p>
<p><center> <INPUT TYPE="SUBMIT" NAME="view_records" VALUE="Submit"> <INPUT TYPE="RESET" VALUE="Reset Form"></center></p>

</blockquote>
<!-BEGIN FOOTER --></td>
</tr>
<tr>
<td width="134"></td>
<td width="476"><hr>
<table border="0" width="468">
<tr>
<td width="74" align="center"><img src="http://www.alldata.com/pro/images/toolart-noback.JPG" width="79" height="56" alt="ALLDATA: The Ultimate Tool.JPG (6792 bytes)" border="0"></td>
<td width="56" align="center" valign="middle"><a href="http://www.alldata.com/pro/index.htm"><font face="Arial" size="2" color="#000080"><strong>HOME</strong></font></a></td>
<td width="171" align="center" valign="middle"><strong><a href="#top"><font face="Arial" size="2" color="#000080">TOP OF THE PAGE</font></a></strong></td>
<td width="76" align="center" valign="middle"><a href="http://www.alldata.com/pro/sitemap/sitemap.htm"><font face="Arial" size="2" color="#000080"><strong>SITE MAP</strong></font></a></td>
<td width="74" align="center"><img src="http://www.alldata.com/pro/images/toolart-noback.JPG" width="79" height="56" alt="ALLDATA: The Ultimate Tool.JPG (6792 bytes)" border="0"></td>
</tr>
</table>
<div align="center"><center><table border="0" cellspacing="0" width="465" bgcolor="#0F5A9F">
<tr>
<td align="center" face="Arial" size="1"><!--webbot bot="HTMLMarkup" StartSpan -->
<td align="center"><a href="http://www.alldata.com/pro/recallsbulletins/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">Recalls/Bulletins</font></strong></a></td>
<td align="center"><strong><font color="#FFFF00" face="Arial" size="2">&#149;</font><strong></td>
<td align="center"><a href="http://www.alldata.com/pro/products/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">Products</font></strong></a><strong></td>
<td align="center"><strong><font color="#FFFF00" face="Arial" size="2">&#149;</font><strong></td>
<td align="center"><a href="http://www.alldata.com/pro/free/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">Free!</font></strong></a></td>
<td align="center"><strong><font color="#FFFF00" face="Arial" size="2">&#149;</font><strong></td>
<td align="center"><a href="http://www.alldata.com/pro/inside/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">Inside ALLDATA</font><strong></a><strong></td>
<!--webbot BOT="HTMLMarkup" endspan --></td>
</tr>
</table>
</center></div><div align="center"><center><table border="0" cellspacing="0" width="465" bgcolor="#0F5A9F">
<tr>
<td align="center" face="Arial" size="1"><!--webbot bot="HTMLMarkup" StartSpan -->

<td align="center"><a href="http://www.alldata.com/pro/whatsnew/index.htm"><strong><font color="#FAFAFA" face="Arial" size="1">What's New!</font><strong></a><strong></td>
<td align="center"><strong><font color="#FFFF00" face="Ari
Quote Reply
Re: links with NULL In reply to
What I'd like to do with the code is this:

When some one searches for a record and the return comes back I'd like it to do this:

Store_Name (if there is a URL for this field check URL and high the Store_Name other wise just print the Store_name without a hyper link)
Address
City, State Zip
Phone

Is this something that can be done? How do I do this?
Quote Reply
Re: links with NULL In reply to
First of all, when I went to the URL you gave:
http://www.alldata.com/pro/free/smartshops_new.html

I got a 404 error -- file not found.

Second, it does not appear that you have a place to enter the store name in your html_record_form. All I see is City, State and Zip, but you want to print out Store_Name, URL, Address and Phone in addition. Are you entering this information somewhere else?



------------------
JPD
Quote Reply
Re: links with NULL In reply to
The other information is in the database, but I'm only letting users search the database using zip, city, and state.

the address is: http://www.alldata.com/pro/free/smartshops_new.html

This is where the users can search from, I think you'll know what I'm trying to do when you see it.

chris
Quote Reply
Re: links with NULL In reply to
So you don't want to be able to add any new stores to your data? Or you're going to enter them into your database by hand? Okay.

I see a possible problem.

print qq|<a href="$rec{'URL'}>$rec{'Store_Name'}|;

You left out a " in there. Should be

<a href="$rec{'URL'}">

I don't know what else it could be, though.

------------------
JPD

PS. I just looked at your site again. I'm not sure why the NULL is showing up, but there's a way around it.

unless ($rec{'URL'} eq 'NULL') {
print qq|<a href="$rec{'URL'}">$rec{'Store_Name'}|;
}
else {
print qq|$rec{'Store_Name'}|;
}

or

if ($rec{'URL'} =~ /^http/) {
print qq|<a href="$rec{'URL'}">$rec{'Store_Name'}|;
}
else {
print qq|$rec{'Store_Name'}|;
}

Probably the second one is the better one to use, since it only shows ones that start with the right format for a URL.

I hope this helps.


[This message has been edited by JPDeni (edited January 16, 1999).]
Quote Reply
Re: links with NULL In reply to
Worked GREAT!!!! Thanks!!!