User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,566 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,659 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1292 | Replies: 8 | Solved
Reply
Join Date: Feb 2005
Posts: 20
Reputation: Stick is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Stick Stick is offline Offline
Newbie Poster

Help Display field as link

  #1  
Dec 12th, 2005
I have a database that returns information about a customer's jobs that have shipped. It displays correctly, but I would like the carrier name to be a link to the carrier's website so the customer can track it on line. I have the carrier's website listed in the database. how do I make the carrier's name print as a link to their website?
Any help would be greatly appreciated!

$resultb = mysql_query("SELECT * FROM orders WHERE mold='$mold' and shipdate is not null",$db);

if ($myrow = mysql_fetch_array($resultb)) {

echo "<BR/><table cellpadding=\"3\" cellspacing=\"3\" border=\"0\">\n";

echo "<tr bgcolor=\"#B9B8B8\"><td><span class=\"bold\">Mold Number</span></td><td><span
class=\"bold\">Date Shipped</span></td><td><span class=\"bold\">Carrier</span></td><td><span class=\"bold\">Tracking Number,</span></td></tr>\n";

do {



printf("<tr bgcolor=\"#EAE8E8\"><td>%s</td><td>%s</td><td>%s</tr>\n", $myrow["mold"],$myrow["shipdate"], $myrow["carrier"], $myrow["tracking"]);

} while ($myrow = mysql_fetch_array($resultb));

}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2004
Location: Sydney, Australia
Posts: 166
Reputation: Lafinboy is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 7
Lafinboy's Avatar
Lafinboy Lafinboy is offline Offline
Junior Poster

Re: Display field as link

  #2  
Dec 13th, 2005
Where is the carriers website address stored? Is it in the orders table? If not then you will need to modify your sql statement to perform a join to the table containing the carrier website address. You can then modify your do loop to build a standard href attibute around the carrier name.
If I've been a help please confirm by clicking the Add to Lafinboy's Reputation link in the header of this reply.

Lafinboy Productions
:: Website Design :: Website Development ::

Reply With Quote  
Join Date: Feb 2005
Posts: 20
Reputation: Stick is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Stick Stick is offline Offline
Newbie Poster

Re: Display field as link

  #3  
Dec 13th, 2005
Thanks Lafinboy,
The web address is located in the website field of the orders table, but I'm not sure how to build a standard href attibute around the carrier name.

Stick
Reply With Quote  
Join Date: Jul 2004
Location: Sydney, Australia
Posts: 166
Reputation: Lafinboy is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 7
Lafinboy's Avatar
Lafinboy Lafinboy is offline Offline
Junior Poster

Re: Display field as link

  #4  
Dec 13th, 2005
Try this:
do {
 printf("<tr bgcolor=\"#EAE8E8\"><td>%s</td><td>%s</td><td><a href=\"%s\">%s</a></td><td>%s</td>\n", $myrow["mold"],$myrow["shipdate"], $myrow["carrier"], $myrow["tracking"]);
}
If I've been a help please confirm by clicking the Add to Lafinboy's Reputation link in the header of this reply.

Lafinboy Productions
:: Website Design :: Website Development ::

Reply With Quote  
Join Date: Feb 2005
Posts: 20
Reputation: Stick is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Stick Stick is offline Offline
Newbie Poster

Re: Display field as link

  #5  
Dec 14th, 2005
It gave me this error. "Warning: printf(): Too few arguments "
Reply With Quote  
Join Date: Jul 2004
Location: Sydney, Australia
Posts: 166
Reputation: Lafinboy is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 7
Lafinboy's Avatar
Lafinboy Lafinboy is offline Offline
Junior Poster

Re: Display field as link

  #6  
Dec 14th, 2005
Sorry, missed out one of the carrier calls. Should read:
 do {
 printf("<tr bgcolor=\"#EAE8E8\"><td>%s</td><td>%s</td><td><a href=\"%s\">%s</a></td><td>%s</td></tr>\n", $myrow["mold"],$myrow["shipdate"], $myrow["carrier"], $myrow["carrier"]
, $myrow["tracking"]);
}
If I've been a help please confirm by clicking the Add to Lafinboy's Reputation link in the header of this reply.

Lafinboy Productions
:: Website Design :: Website Development ::

Reply With Quote  
Join Date: Feb 2005
Posts: 20
Reputation: Stick is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Stick Stick is offline Offline
Newbie Poster

Re: Display field as link

  #7  
Dec 14th, 2005
That almost worked.
Now it gives the path of http://www.mydomain.com/www.carriers domain.com
I want it to be http://www.carriers domain.com
Reply With Quote  
Join Date: Jul 2004
Location: Sydney, Australia
Posts: 166
Reputation: Lafinboy is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 7
Lafinboy's Avatar
Lafinboy Lafinboy is offline Offline
Junior Poster

Re: Display field as link

  #8  
Dec 14th, 2005
How is the carriers url stored in the database? If it is just in the format www.carriersdomain.com then you will need to force the http:// onto the front of it, otherwise the system assumes it is a local path. Try:
do {
 printf("<tr bgcolor=\"#EAE8E8\"><td>%s</td><td>%s</td><td><a href=\"http://%s\">%s</a></td><td>%s</td></tr>\n", $myrow["mold"],$myrow["shipdate"], $myrow["carrier"], $myrow["carrier"]
, $myrow["tracking"]);
}
If I've been a help please confirm by clicking the Add to Lafinboy's Reputation link in the header of this reply.

Lafinboy Productions
:: Website Design :: Website Development ::

Reply With Quote  
Join Date: Feb 2005
Posts: 20
Reputation: Stick is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Stick Stick is offline Offline
Newbie Poster

Re: Display field as link

  #9  
Dec 15th, 2005
That gave me a result of http://www.mydomain.com/carriers name.
So I changed the script to
printf("<tr bgcolor=\"#EAE8E8\"><td>%s</td><td>%s</td><td><a href=\"http:\\%s\">%s</a></td><td>%s</td></tr>\n", $myrow["mold"],$myrow["shipdate"], $myrow["website"], $myrow["carrier"]
, $myrow["tracking"]);

That gave me a result of http://www.mydomain.com/www.carriersdomain.com.

So I changed the carriers web address in the database to http://www.carriersdomain.com.

That gave me a result of http://www.mydomain.com/http://www.carriersdomain.com.

I am using a mysql database, and have the field type set to varchar.
Is it possible that the field type is incorrect?

I have a test order set up in the database. If you would like to see how it is working, I can email you the domain with the user name and password for the test order.

Thanks
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:23 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC