Page 1 of 1
Help displaying topics
Posted: Wed Jul 04, 2007 8:57 pm
by YellowShadow101
I'm making a small forums system for my site and I need some help.
I'm following this tutorial:
http://www.phpeasystep.com/workshopview.php?id=12
and my server has PHP5.
I can't get the topic to show as a link. The code is this:
Code: Select all
<a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['topic']; ?></a>
If I do
I can get the topic title to display but not as a link.
Can anyone help me?
Posted: Wed Jul 04, 2007 9:05 pm
by Zoxive
Can you post the code you have written? There could be an error elsewhere causing this.
Posted: Wed Jul 04, 2007 10:03 pm
by YellowShadow101
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
All of it?
Okay here I go:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Aluon Studios | Forum</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="author" content="fullahead.org - studio7designs.com" />
<meta name="description" content="Aluon Studios is an independent game development company started in 2007." />
<meta name="keywords" content="Aluon Studios, Utopia, Aluon, Xbox 360, Games, Xbox, Xbox Live, Live, indie, developer, indiependent game developer" />
<meta name="robots" content="index, follow, noarchive" />
<meta name="googlebot" content="noarchive" />
<link rel="stylesheet" type="text/css" href="layout.css" media="screen, projection, tv " />
<link rel="stylesheet" type="text/css" href="html.css" media="screen, projection, tv " />
<!-- CSS specific to current theme -->
<link rel="stylesheet" type="text/css" href="css/light.css" title="light" media="screen, projection, tv " />
<link rel="alternate stylesheet" type="text/css" href="css/dark.css" title="dark" media="screen, projection, tv " />
</head>
<body>
<div id="content"><!-- #header: holds the logo and top links -->
<div id="header" class="width"> <img src="logo.gif" alt="Your logo goes here" />
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="games.php">Games</a></li>
<li><a href="tech.php">Technology</a></li>
<li><a href="/forum/main_forum.php">Forums</a></li>
<li><a href="about.php">About Us</a></li>
<li><a href="contact.php" class="last">Contact
Us</a></li>
</ul>
</div>
<!-- #header end --><!-- #headerImg: holds the main header image or flash -->
<div id="headerImg" class="width"></div>
<!-- #menu: the main large box site menu -->
<!-- #menu end --><!-- #page: holds the page content -->
<div id="page"><!-- #columns: holds the columns of the page -->
<div id="columns" class="widthPad"><!-- Left column -->
<div class="floatLeft width73"><br />
<?php $host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="forum"; // Database name
$tbl_name="forum_question"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name ORDER BY id DESC";
// OREDER BY id DESC is order result by descending
$result=mysql_query($sql);
?>
<table align="center" bgcolor="#cccccc" border="0" cellpadding="3" cellspacing="1" width="90%">
<tbody>
<tr>
<td align="center" bgcolor="#e6e6e6" width="6%"><strong>#</strong></td>
<td align="center" bgcolor="#e6e6e6" width="53%"><strong>Topic</strong></td>
<td align="center" bgcolor="#e6e6e6" width="15%"><strong>Views</strong></td>
<td align="center" bgcolor="#e6e6e6" width="13%"><strong>Replies</strong></td>
<td align="center" bgcolor="#e6e6e6" width="13%"><strong>Date/Time</strong></td>
</tr>
<?php while($rows=mysql_fetch_array($result)){ // Start looping table row
?>
<tr>
<td bgcolor="#ffffff"><?php echo $rows ['id'];?></td>
<td bgcolor="#ffffff"><?php <a href="view_topic.php?id=<? echo $rows['id']; ?>">?><br />
</td>
<td align="center" bgcolor="#ffffff"><?php echo $rows ['view'];?></td>
<td align="center" bgcolor="#ffffff"><?php echo $rows ['reply'];?></td>
<td align="center" bgcolor="#ffffff"><?php echo $rows ['datetime'];?></td>
</tr>
<?php // Exit looping and close connection
}
mysql_close();
?>
<tr>
<td colspan="5" align="right" bgcolor="#e6e6e6"><a href="create_topic.php"><strong>Create New Topic</strong>
</a></td>
</tr>
</tbody>
</table>
</div>
<!-- Left column end --><!-- Right link column -->
<div class="floatRight width25 lightBlueBg horzPad">
<h2>Links<span class="dark"></span></h2>
<ul class="submenu1">
<li><a href="http://www.modernmoviei.com">Modern
Move Industries</a></li>
<li><a href="http://www.yellowshadow101.blogspot.com">My
Blog </a></li>
<li><a href="http://www.garagegames.com">Garage
Games</a></li>
<li><a href="http://www.xna.com">XNA </a></li>
<li><a href="http://www.creators.xna.com">XNA
Creators Club</a></li>
</ul>
</div>
<!-- Right links column end --> </div>
<!-- #columns end --> </div>
<!-- #page end --></div>
<!-- #content end -->
<!-- #footer: holds the site footer (logo and links) -->
<div id="footer"><!-- #bg: applies the site width and footer background -->
<div id="bg" class="width"> <img src="logo.gif" alt="Your logo goes here" />
<ul>
<li><a href="">Copyright © 2007 Aluon
Studios. All
Rights Reserved.</a></li>
<li><a href="http://www.studio7designs.com" class="last">Design by: studio7designs.com</a></li>
</ul>
</div>
<!-- #bg end --></div>
<!-- #footer end -->
</body>
</html>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Wed Jul 04, 2007 10:28 pm
by Zoxive
Code: Select all
<td bgcolor="#ffffff"><?php <a href="view_topic.php?id=<? echo $rows['id']; ?>">?><br />
should be
Code: Select all
<td bgcolor="#ffffff"><a href="view_topic.php?id=<?php echo $rows['id']; ?>"><?php echo $rows['topic']; ?></a><br />
It could also because you have short tags, just <? ?> in some places.
But to me thats to many php openings and closings.
Code: Select all
<?php
echo '<td bgcolor="#ffffff"><a href="view_topic.php?id=' . $rows['id'] . '">' . $rows['topic'] . '</a><br />';
?>
Posted: Wed Jul 04, 2007 10:51 pm
by YellowShadow101
Thank you
It works.