Jump to content

Recommended Posts

Hi i am doing a database for a college project and i am getting really confused, my code is the following:

<HTML>
<BODY>
<body bgcolor="#FFFFCC" text="#006600" link="#0000FF" vlink="#0000FF" alink="#0000FF">
<?php
$db=mysql_connect("localhost","hnd","");
mysql_select_db("hnd",$db);
$result=mysql_query("SELECT * FROM RB_Products",$db);
echo "<table border=1>\n";
echo "<TR>
<TD><h2>Item Number</h2></TD>
<TD><h2>Item Name</h2></TD>
<TD><h2>Cost</h2></TD>
<TD><h2>Postage</h2></TD>
<TD><h2>Category</h2></TD>
<TD><h2>In Stock</h2></TD>
<TD><h2>Image</h2></TD>
<TD><h2>Order</h2></TD>
</TR>\n";
while($myrow = mysql_fetch_array($result)){

echo
"<TR>
<TD><h3>$myrow[0]</h3></TD>
<TD><h3>$myrow[1]</h3></TD>
<TD><h3>$myrow[2]</h3></TD>
<TD><h3>$myrow[3]</h3></TD>
<TD><h3>$myrow[4]</h3></TD>
<TD><h3>$myrow[5]</h3></TD>
<TD><img src=$myrow[6]></TD>
<TD><a href=$myrow[7]></TD>
</TR>";
}
echo "</table>\n";
?>
</BODY>
</HTML>

how do i make the line "<TD><a href=$myrow[7]></TD>" display a link when something is typed in? so far when something is typed into the form it shows up when i look in the actual database but it doesnt display in this view stock section, how can i make it so that if i type in for example orderitem1.html how can i make it so it makes it a link to click? [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /]

Link to comment
https://forums.phpfreaks.com/topic/12095-php-database-link-show-a-link/
Share on other sites

I am about to have to do something similar, so this will help both of us, but I was pointed in the direction earlier of creating the following code, something to go by anyway.
for the 3 oldest
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]SELECT * FROM `records` ORDER BY date ASC LIMIT 3[/quote]

for the 3 newest
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]SELECT * FROM `records` ORDER BY date DESC LIMIT 3[/quote]
These will sort them based on date, but there might be other ways to do this as well, but when you sort just have it sort the fields with a url, or have it display the urls, but sort by the other field, I don't know but some ideas.
[!--quoteo(post=384327:date=Jun 15 2006, 08:15 PM:name=annihilate)--][div class=\'quotetop\']QUOTE(annihilate @ Jun 15 2006, 08:15 PM) [snapback]384327[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]echo '<TD><a href="'.$myrow['7'].'">Link</a></TD>';[/code]
[/quote]


This doesnt work


I dont understand what you mean businessman332211
<HTML>
<BODY>
<body bgcolor="#FFFFCC" text="#006600" link="#0000FF" vlink="#0000FF" alink="#0000FF">
<?php
$db=mysql_connect("localhost","hnd","");
mysql_select_db("hnd",$db);
$result=mysql_query("SELECT * FROM RB_Products",$db);
echo "<table border=1>\n";
echo "<TR>
<TD><h2>Item Number</h2></TD>
<TD><h2>Item Name</h2></TD>
<TD><h2>Cost</h2></TD>
<TD><h2>Postage</h2></TD>
<TD><h2>Category</h2></TD>
<TD><h2>In Stock</h2></TD>
<TD><h2>Image</h2></TD>
<TD><h2>Order</h2></TD>
</TR>\n";
while($myrow = mysql_fetch_array($result)){

echo
"<TR>
<TD><h3>$myrow[0]</h3></TD>
<TD><h3>$myrow[1]</h3></TD>
<TD><h3>$myrow[2]</h3></TD>
<TD><h3>$myrow[3]</h3></TD>
<TD><h3>$myrow[4]</h3></TD>
<TD><h3>$myrow[5]</h3></TD>
<TD><img src=$myrow[6]></TD>
(line 30!)echo '<TD><a href="'.$myrow[7].'">Link</a></TD>';
</TR>";
}
echo "</table>\n";
?>
</BODY>
</HTML>


there is a ; at the end, still doesnt work...
If you have just copied and pasted my code then it wont work as my code works on the premise that your echo statements use single quotes rather than double quotes. So here is the full echo statement with your img tag fixed as well.

[code]echo
'<TR>
<TD><h3>$myrow[0]</h3></TD>
<TD><h3>$myrow[1]</h3></TD>
<TD><h3>$myrow[2]</h3></TD>
<TD><h3>$myrow[3]</h3></TD>
<TD><h3>$myrow[4]</h3></TD>
<TD><h3>$myrow[5]</h3></TD>
<TD><img src="'.$myrow[6].'" alt="Image" /></TD>
<TD><a href="'.$myrow[7].'">Link</a></TD>
</TR>';
}
echo "</table>\n";[/code]
[!--quoteo(post=384344:date=Jun 15 2006, 09:05 PM:name=businessman332211)--][div class=\'quotetop\']QUOTE(businessman332211 @ Jun 15 2006, 09:05 PM) [snapback]384344[/snapback][/div][div class=\'quotemain\'][!--quotec--]
he is right I recently found out you can't do concatenations with single quoted strings, you have to use double quotes
[/quote]
You can, you would just swap each one round, ie where you had a double quote, put a single quote.
[code]echo "<a href='".$row[1]."'>Link</a>";[/code]
[!--quoteo(post=384526:date=Jun 16 2006, 11:28 AM:name=howrandom)--][div class=\'quotetop\']QUOTE(howrandom @ Jun 16 2006, 11:28 AM) [snapback]384526[/snapback][/div][div class=\'quotemain\'][!--quotec--]
yes this works i can click on the links but now the data doesnt show it will just paste "$myrow[0] or 1 in the according field but the link is working
[/quote]
Post the page that the link is gooing to ok.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.