Linking to webpage (Desperately in need of help!!)

R

Rudy

I am desperately seeking some help with a program that was supposed to have
been completed last night. I have only been working with PHP for a week. I
have tried and tried and tried, but I am unable to get this program to work.
I posted a question earlier this week "Linking Query Results to a webpage",
however I could never figure out where to add the code and my client added
another complexity (open into a new window).

I have a very simple query that is writing out 4 variables from a 'mysql'
database. One of the variables is a 'url' (ie, www.pfo.biz,
www.corbanusa.com , etc.). I am trying to display the 'url' on a webpage and
let users click on the URL. When they click on the URL it NEEDS to open into
a new window.

I AM VERY BEHIND ON THIS PROJECT..and the little hair I had left I've
already pulled it out!

I am including my program below. The program is very simple and short. If
someone could please cut & paste the code directly into my program, so that
stupid me can't screw it up, I would really appreciate it. Again, I am sorry
for being so stupid this week Can somebody please help me!!!!!! Thanks!


BELOW IS MY CODE

<html><head><title>Get data</title></head>

<body>

<?php

$conn=@mysql_connect("localhost", "root", "")
or die("Err:Conn");
#select the specified database
$rs = @mysql_select_db("autoclub", $conn)
or die("Err:Db");

#create the query
$sql= "SELECT * from nc";

#execute the query
$rs=mysql_query($sql,$conn);

#write the data
while ( $row = mysql_fetch_array($rs) )
{
echo($row["name"]."<br>");
echo($row["address1"]."<br>");
echo($row["cszip"]."<br>");
echo($row["url"]."<br>");
}
?>
</body></html>
 
J

J.O. Aho

Rudy said:
<html><head><title>Get data</title></head>

<body>

<?php

$conn=@mysql_connect("localhost", "root", "")
or die("Err:Conn");
#select the specified database
$rs = @mysql_select_db("autoclub", $conn)
or die("Err:Db");

#create the query
$sql= "SELECT * from nc";

#execute the query
$rs=mysql_query($sql,$conn);

#write the data
while ( $row = mysql_fetch_array($rs) )
{
echo($row["name"]."<br>");
echo($row["address1"]."<br>");
echo($row["cszip"]."<br>");
/* We modify the next line, this requiers that the url from
the db DON'T includes the http:// part of the url */
 
R

Rudy

Great! That works great! Thank you so much for your help!

Rudy


J.O. Aho said:
Rudy said:
<html><head><title>Get data</title></head>

<body>

<?php

$conn=@mysql_connect("localhost", "root", "")
or die("Err:Conn");
#select the specified database
$rs = @mysql_select_db("autoclub", $conn)
or die("Err:Db");

#create the query
$sql= "SELECT * from nc";

#execute the query
$rs=mysql_query($sql,$conn);

#write the data
while ( $row = mysql_fetch_array($rs) )
{
echo($row["name"]."<br>");
echo($row["address1"]."<br>");
echo($row["cszip"]."<br>");
/* We modify the next line, this requiers that the url from
the db DON'T includes the http:// part of the url */
echo "<a href=\"http://" . $row["url"] . "\">" . $row["url"]
.. said:
}
?>
</body></html>
 
R

Rudy

Hilario,

Thank you so much for your help. I really love the layout! There is one
small problem. When it "OPENS" a new window the URL appears within the
directory. For example:

When I click on a URL ( www.pfo.biz ) , the new window "opens" to
http://localhost/mysql/www.pfo.biz . All of the URLs are opening to the
directory like this. When I upload it to my site on the internet, it "opens"
to http://www.williams-global.com/www.pfo.biz . How can I get it to just
"open" to http://www.pfo.biz ?

Thanks so much for your help! That really looks good.


Rudy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top