Original Post Table:
poster: name of user that posted the topic
topic
post
Replies to posts:
replier: who posted it
reply_topic: what the person is replying to (used to show only relevant rows)
reply_post: content
I want to use reply_topic to show rows of data from the reply table that are relevant to the original post. What would I need to add in to do this? Currently, with the code (below), all of the data, regardless of where it was posted to, is displayed on every topic. If I wasn't clear enough, please let me know!
- Code: Select all
Head:
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$colname_main_topic = "-1";
if (isset($_GET['post'])) {
$colname_main_topic = $_GET['post'];
}
mysql_select_db($database_mysql1, $mysql1);
$query_main_topic = sprintf("SELECT * FROM aka_forum_main_post WHERE post = %s", GetSQLValueString($colname_main_topic, "text"));
$main_topic = mysql_query($query_main_topic, $mysql1) or die(mysql_error());
$row_main_topic = mysql_fetch_assoc($main_topic);
$totalRows_main_topic = mysql_num_rows($main_topic);
mysql_select_db($database_mysql1, $mysql1);
$query_replies = "SELECT * FROM aka_forum_post_reply";
$replies = mysql_query($query_replies, $mysql1) or die(mysql_error());
$row_replies = mysql_fetch_assoc($replies);
$totalRows_replies = mysql_num_rows($replies);
?>
- Code: Select all
Body:
<!-- start original post -->
<table width="500" border="1">
<tr>
<td width="100"><?php echo $row_main_topic['poster']; ?></td>
<td width="400"><?php echo $row_main_topic['post']; ?></td>
</tr>
</table>
<!-- start all replies -->
<table border="1" width="500">
<tr>
<td width="100">replier</td>
<td width="400">reply_post</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_replies['replier']; ?></td>
<td><?php echo $row_replies['reply_post']; ?></td>
</tr>
<?php } while ($row_replies = mysql_fetch_assoc($replies)); ?>
</table>


