Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP/MYSQL

Status
Not open for further replies.

183391

Technical User
Apr 3, 2002
6
US
Need help. Of course why would I be writing this. If using two rows such as print first name and another print statement for last name, how would I create a space between the two. Also how would I create the output to be an html link to something such as another page or picture.
 
If I get what you mean ... 2 cols in db called say fname and sname, do this in your php page ...

<HTML header stuff ..>
<?php
// assume connection etc set up ok...
$sql=&quot;select fname, sname from mytable where key='somekeyval'&quot;;
$result=mysql_query($sql,$conn);
@$rows=mysql_num_rows($result);
if($rows>0){
$fn=mysql_result($result,0,&quot;fname&quot;);
$sn=mysql_result($result,0,&quot;sname&quot;);
echo &quot;<b>Name:</b> $fn $sn<BR>&quot;;
}
?>
<more static HTML>
</BODY></HTML>


should do the trick ...

for links, change echo to

echo &quot;<b>Name:</b> $fn <a href=\&quot;myurl.php3\&quot;>$sn</a>&quot;;

so surname is a link...


David.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top