No mouse click to a url pull using php

I have a large mysql db. One of the tables is “shop”. fields include shop_id, name, … and finally url.

In the past I have published this with minor formatting, but basically line after line.

If the listing has a url, I want to do a _target, generate a new page and send the visitor directly to the url.

If there is no url, I am fine with what I have been doing.

An if-else does the work. Almost

I don’t remember how to go directly to the new url without some mouse clicking.

Can you tell me where to check? thanks

hi cups

my struggle was finding the header(). Got that so I am good to go.

To clear up the url vs other shop data:

I have all of that in the mysql table. There are going to be several kickback items. Now if they have a url they will need to keep it up to date. If they drop it and do not tell me - hello 404. And other things.

The site was fashioned after Kevin’s pub of the 10 lessons that became his first book. most of my tables are small. The one exception is shop. I do a lot of joins.

Thanks for all the help. All of your comments are really useful.



Are you saying that if the url field is found to contain some data, you want your page to still show all the details, but you want to pop open a new browser window with the target site contained within it?

If so that seems to be a usability nightmare to me - why do that?

hi cups and thanks for the reply. To your question - No. I was not clear.
In brief:
my log in to server here.
$query=“select url from shop where shop_id =‘$_GET[id]’”;
$result=mysql_query($query) or die(“Cannot execute query”);
while ($row=mysql_fetch_array($result)){
$url=$row[“url”]; this is in the form of www.domain name

if ($url != “”) {
header(location:http://); I will try this to a fixed location and then to a variable.

my log in to server here. May not be needed but we shall see.
$query=“select * from shop where shop_id=‘$_GET[id]’”;
$result=mysql_query($query) or die(“Cannot execute query”);
while ($row=mysql_fetch_array($result)){
and this goes on to all the other fields in the table. About 15 more.

Since I posted, I found the header() and now I just have to work out how to load the variable.

I could just pull the data and if the url is occupied, dump the balance

The whys: It is a neighborhood site with about 700 businesses. Some have a web site some do not. I need everyone listed in order to be useful. Nearly all take the view that I have some manner of third eye and auto track their movements. Of course this is wrong. We have up to 5 new and 4 or 5 going out of business each month. Just following them is a nightmare.

I am completely redoing my site. Even the editor - DWcs5.5 arrives Monday!!! Yea!!!

Welcome comments about the double query. I am a bit cautious about that. Comments about the header() and how I might slip in the query. I am thinking (‘“Location: http://” . $url . “/ target= _blank”’);. (I have a bit more to do in the _blank area.



OK, let me try this. If a shop has a url, you want the user to get taken to that shop.

If the shop does not have website, then fetch and display as much detail as possible.

I guess the easy answer is to retrieve everything where id = $_GET[id], then analyse the url first and do a header(Location: $url) as you have said, else, show all the details.

Which bit are you struggling with?

There might be a less wasteful way of doing it in that your sql statement could check that url IS NOT NULL otherwise select everything, but I do not have that solution to hand, but I have used something similar.

It would be less wasteful because if url DOES contain a value, then you just retrieve that one field rather than selecting everything, and then dumping it because you are doing the redirect straight away.