Posted: Thu Feb 08, 2007 8:08 pm
Psst.. only CommentFrom and CommentMessage will be in the result set. 
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
feyd wrote:Psst.. only CommentFrom and CommentMessage will be in the result set.
It is not working because, as feyd said, the CommentTO field is not being selected. You, I and the rest of the contibutors up to now had totally overlooked that point. Here is the query you are executing. Basically you are asking the database to serve you the CommentFrom column and the CommentMessage column from the table where the CommentTO value is equal to the value of the $profileid variable. But in the loop, where you are checking for $row['CommentTO'], it will always be null (or not set) because it is not coming out of the database, only CommentFrom and Comment Message are being served.4Boredom wrote:Im just showing the result for what he asked me to process.
I have no clue why its not working...
Code: Select all
<?php
$sql = "SELECT `CommentFrom`, `CommentMessage` FROM `comments` WHERE `CommentTO`= $profileid";
?>Code: Select all
<?php
$sql = "SELECT `CommentTO`, `CommentFrom`, `CommentMessage` FROM `comments` WHERE `CommentTO`= $profileid";
?>Code: Select all
<?php
$c = 0;
?>Code: Select all
<?php
define('profile','1');
define('protect','1');
require_once("/home/i4boredo/protected_html/main.php");
$sql = "SELECT `CommentTO`, `CommentFrom`, `CommentMessage` FROM `comments` WHERE `CommentTO`= $profileid";
if (!$result = mysql_query($sql))
{
die(mysql_error());
}
echo '<a href="viewprofile?userid=' . $profileid . '&CommentID=index">';
while ($row = mysql_fetch_array($result))
{
echo $row['CommentTO'] . ' is the value for CommentTO at loop position <br />';
}
echo '</a>';
?>We understand completely. We also understand that you have been around for a while and that putting PHP output into simple HTML is something that you should already know how to do.4Boredom wrote:That did absolutely nothing to the output
Maybe people dont understand what is needed
Code: Select all
<?php
define('profile','1');
define('protect','1');
require_once("/home/i4boredo/protected_html/main.php");
$sql = "SELECT `CommentTO`, `CommentFrom`, `CommentMessage` FROM `comments` WHERE `CommentTO`= $profileid";
if (!$result = mysql_query($sql))
{
die(mysql_error());
}
?>Code: Select all
<?php
echo '<table border="1">';
while ($row = mysql_fetch_array($result))
{
echo '<tr><td>' . $row['CommentFrom'] . '</td><td>' . $row['CommentMessage'] . '</td></tr>';
}
echo '</table>';
?>Code: Select all
<?php
define('profile','1');
define('protect','1');
require_once("/home/i4boredo/protected_html/main.php");
$sql = "SELECT `CommentTO`, `CommentFROM`, `CommentMESSAGE` FROM `comments` WHERE `CommentTO`= $profileid";
$name = "SELECT `username` FROM `users` WHERE `username` = `CommentFROM`";
if (!$result = mysql_query($sql))
{
die(mysql_error());
}
echo '<table border="0" width="100%">';
while ($row = mysql_fetch_array($result))
{
echo '<tr><td width="25%">' . $row['CommentFROM'] . '</td>
<td width="3%"></td><td width="72%">' . $row['CommentMESSAGE'] . '</td></tr>
<tr><td><br></td></tr>';
}
echo '</table>';
?>Code: Select all
<?php
$users = array();
// Do the query, get the result. Then loop
while ($row = mysql_fetch_array($result))
{
$users[$row['userId']] = $row['userName'];
}
?>Code: Select all
<?php
while ($row = mysql_fetch_array($result))
{
echo '<tr><td width="25%">' . $users[$row['CommentFROM']] . '</td>
<td width="3%"></td><td width="72%">' . $row['CommentMESSAGE'] . '</td></tr>
<tr><td><br></td></tr>';
}
?>