473,779 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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><ti tle>Get data</title></head>

<body>

<?php

$conn=@mysql_co nnect("localhos t", "root", "")
or die("Err:Conn") ;
#select the specified database
$rs = @mysql_select_d b("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_arr ay($rs) )
{
echo($row["name"]."<br>");
echo($row["address1"]."<br>");
echo($row["cszip"]."<br>");
echo($row["url"]."<br>");
}
?>
</body></html>
Jul 23 '05 #1
5 1628
Rudy wrote:
<html><head><ti tle>Get data</title></head>

<body>

<?php

$conn=@mysql_co nnect("localhos t", "root", "")
or die("Err:Conn") ;
#select the specified database
$rs = @mysql_select_d b("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_arr ay($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"] ."</a><br>"; }
?>
</body></html>

Jul 23 '05 #2
<html>
<head>
<title>Get data</title>
</head>
<body>
<?php
error_reporting ( E_ALL ); // turn off in production

$conn = @mysql_connect( 'localhost', 'root', '' );
if (!$conn)
{
echo "Err:Conn<b r />\n";
echo mysql_error() . "<br />\n"; // turn off in production
die(" </body>\n</html>");
}

if (!@mysql_select _db( 'autoclub', $conn ))
{
echo "Err:Db<br />\n";
echo mysql_error( $conn ) . "<br />\n"; // turn off in production
die(" </body>\n</html>");
}

// create the query
$sql = 'SELECT name, address1, cszip, url FROM nc ORDER BY name';

// execute the query
$rs = @mysql_query( $sql, $conn );
// query can also fail !!
if (!$rs)
{
echo "Err:Qry<br />\n";
echo mysql_error() . "<br />\n"; // turn off in production
die(" </body>\n</html>");
}
?>

<table border="1" cellspacing="0" cellpadding="3" >
<thead>
<tr>
<th>name</th>
<th>address1</th>
<th>cszip</th>
<th>url</th>
</tr>
</thead>
<tbody>
<?php

// write the data
while ( $row = mysql_fetch_arr ay( $rs ) )
{
echo " <tr>\n";

echo ' <td>';
echo htmlspecialchar s( $row['name'] );
echo "</td>\n";
echo ' <td>';
echo htmlspecialchar s( $row['address1'] );
echo "</td>\n";

echo ' <td>';
echo htmlspecialchar s( $row['cszip'] );
echo "</td>\n";

// Use the url for 'href' atribute value
// and for anchor text. Atribute target="_blank"
// tells browser to open the url in new
// standard browser window. If you want it to
// be "special" (no addressbar wtc.), then you'll
// have to use JavaScript or another client-side
// mechanism.
echo ' <td><a href="';
echo htmlspecialchar s( $row['url'] );
echo '" target="_blank" >';
echo htmlspecialchar s( $row['url'] );
echo "</a></td>\n";

echo " </tr>\n";
}
?>
</tbody>
</table>
</body>
</html>
Jul 23 '05 #3
Great! That works great! Thank you so much for your help!

Rudy
"J.O. Aho" <us**@example.n et> wrote in message
news:30******** *****@uni-berlin.de...
Rudy wrote:
<html><head><ti tle>Get data</title></head>

<body>

<?php

$conn=@mysql_co nnect("localhos t", "root", "")
or die("Err:Conn") ;
#select the specified database
$rs = @mysql_select_d b("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_arr ay($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"]

.."</a><br>";
}
?>
</body></html>

Jul 23 '05 #4
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

"Hilarion" <hi******@SPAM. op.SMIECI.pl> wrote in message
news:cn******** **@nemesis.news .tpi.pl...
<html>
<head>
<title>Get data</title>
</head>
<body>
<?php
error_reporting ( E_ALL ); // turn off in production

$conn = @mysql_connect( 'localhost', 'root', '' );
if (!$conn)
{
echo "Err:Conn<b r />\n";
echo mysql_error() . "<br />\n"; // turn off in production
die(" </body>\n</html>");
}

if (!@mysql_select _db( 'autoclub', $conn ))
{
echo "Err:Db<br />\n";
echo mysql_error( $conn ) . "<br />\n"; // turn off in production
die(" </body>\n</html>");
}

// create the query
$sql = 'SELECT name, address1, cszip, url FROM nc ORDER BY name';

// execute the query
$rs = @mysql_query( $sql, $conn );
// query can also fail !!
if (!$rs)
{
echo "Err:Qry<br />\n";
echo mysql_error() . "<br />\n"; // turn off in production
die(" </body>\n</html>");
}
?>

<table border="1" cellspacing="0" cellpadding="3" >
<thead>
<tr>
<th>name</th>
<th>address1</th>
<th>cszip</th>
<th>url</th>
</tr>
</thead>
<tbody>
<?php

// write the data
while ( $row = mysql_fetch_arr ay( $rs ) )
{
echo " <tr>\n";

echo ' <td>';
echo htmlspecialchar s( $row['name'] );
echo "</td>\n";
echo ' <td>';
echo htmlspecialchar s( $row['address1'] );
echo "</td>\n";

echo ' <td>';
echo htmlspecialchar s( $row['cszip'] );
echo "</td>\n";

// Use the url for 'href' atribute value
// and for anchor text. Atribute target="_blank"
// tells browser to open the url in new
// standard browser window. If you want it to
// be "special" (no addressbar wtc.), then you'll
// have to use JavaScript or another client-side
// mechanism.
echo ' <td><a href="';
echo htmlspecialchar s( $row['url'] );
echo '" target="_blank" >';
echo htmlspecialchar s( $row['url'] );
echo "</a></td>\n";

echo " </tr>\n";
}
?>
</tbody>
</table>
</body>
</html>

Jul 23 '05 #5
I added this line:

==> echo ' <td><a href="http://';

It works great! Thanks you so much!

Rudy

"Hilarion" <hi******@SPAM. op.SMIECI.pl> wrote in message
news:cn******** **@nemesis.news .tpi.pl...
<html>
<head>
<title>Get data</title>
</head>
<body>
<?php
error_reporting ( E_ALL ); // turn off in production

$conn = @mysql_connect( 'localhost', 'root', '' );
if (!$conn)
{
echo "Err:Conn<b r />\n";
echo mysql_error() . "<br />\n"; // turn off in production
die(" </body>\n</html>");
}

if (!@mysql_select _db( 'autoclub', $conn ))
{
echo "Err:Db<br />\n";
echo mysql_error( $conn ) . "<br />\n"; // turn off in production
die(" </body>\n</html>");
}

// create the query
$sql = 'SELECT name, address1, cszip, url FROM nc ORDER BY name';

// execute the query
$rs = @mysql_query( $sql, $conn );
// query can also fail !!
if (!$rs)
{
echo "Err:Qry<br />\n";
echo mysql_error() . "<br />\n"; // turn off in production
die(" </body>\n</html>");
}
?>

<table border="1" cellspacing="0" cellpadding="3" >
<thead>
<tr>
<th>name</th>
<th>address1</th>
<th>cszip</th>
<th>url</th>
</tr>
</thead>
<tbody>
<?php

// write the data
while ( $row = mysql_fetch_arr ay( $rs ) )
{
echo " <tr>\n";

echo ' <td>';
echo htmlspecialchar s( $row['name'] );
echo "</td>\n";
echo ' <td>';
echo htmlspecialchar s( $row['address1'] );
echo "</td>\n";

echo ' <td>';
echo htmlspecialchar s( $row['cszip'] );
echo "</td>\n";

// Use the url for 'href' atribute value
// and for anchor text. Atribute target="_blank"
// tells browser to open the url in new
// standard browser window. If you want it to
// be "special" (no addressbar wtc.), then you'll
// have to use JavaScript or another client-side
// mechanism.
echo ' <td><a href="';
echo htmlspecialchar s( $row['url'] );
echo '" target="_blank" >';
echo htmlspecialchar s( $row['url'] );
echo "</a></td>\n";

echo " </tr>\n";
}
?>
</tbody>
</table>
</body>
</html>

Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1877
by: Rodney King | last post by:
Hi, I have developed an ASP page which dynamically displays a list of checkbox options based on a SQL statement. Here is my code: <div style="OVERFLOW:auto; Height: 150px"> <table> <% dim adOpenForwardOnly, adLockReadOnly dim adCmdTable, ctr, checkboxID
2
2534
by: robert | last post by:
I've made a gallery site for an artist and it works well -- the gallery page has a central large image which is swapped when thumbnail images are clicked. I'm using Dreamweaver's "SwapImage" behavior. The problem is that this fails under certain versions of IE and possibly NN on PCs and Macs -- I haven't gotten my client to send me details of what version he's using (sorry) or any of my 'beta testers' -- but I'm really getting frustrated....
17
1973
by: EkteGjetost | last post by:
This is definitely not the smart thing to do as far as my learning goes, but desperate situations call for desperate measures. The final lab for my introduction to C programming class is due tomorrow. I was on vacation when we went over how to read files, so basically my only resources are the book, the course notes, and the examples. Unfortunately for me, none of them are usefull at all, so pretty much i don't have a clue as to what i...
2
2298
by: Lior | last post by:
Hi, I have an ASP.NET website that crashes under heavy load. I use a SQL Server DB. I get around 5500 hits per day. I keep getting the timeout expieried connection pool error. Sometimes it even throws and error about a DataReader connection being already open even though I only use Data Sets in my code. Please take a look and see if you can find my leak because I'm going nuts here and am losing hope... I keep blaming the server and the...
6
2028
by: Joey Liang via DotNetMonster.com | last post by:
Hi all, I have a drop down list which store all the different brands of product.When i selected the particular brand from the drop down list, it will display all the products with the selected brand in a datagrid. I have this error when i select a brand from the drop down list. Blow is my code,anyone can help me to solve my error,which part of my code went wrong? Really thanx and very appreciate your help in advanced.. I have been stucked...
9
2573
by: Gordon | last post by:
Hello again, Sorry to repost this request, but I'm under a bit of pressure to find a quick solution. All I basically want is an automatically updating link (OLE, not DDE) between a control in my application and a cell in an Excel spreadsheet. My control has to automatically receive updates from the spreadsheet cell. I already know how to access the spreadsheet via the Excel.Application class
8
2087
by: pamelafluente | last post by:
I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work. This is what I need to accomplish: ---------------------- Given button and a TextBox on a web form when one presses the button on the web form on a client pc, the sql query which is contained in the text box is sent to a vb net application on a server pc. The win application sends the query to the database, collects the results,
0
9633
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10305
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10137
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9928
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8959
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.