30secondstosam
-
Posts
4 -
Joined
-
Last visited
Never
Posts posted by 30secondstosam
-
-
excellent
one more thing seeing as you are clearly a genius... need to find out how to space out results from this loop!
function getReasons ($id) { global $link; $result=''; $rst = mysql_query('SELECT r.name as reason FROM entries_feedback_comments as f LEFT JOIN reasons as r ON r.id = f.reason_id WHERE f.feedback_id ='. $id, $link); while ($row = mysql_fetch_assoc($rst)) { $result.=$row['reason']; } return $result; }
the result is shown like this...
e.g. - Result1Result2Result3
I want it to be "Result1 Result2 Result3"
do i have to put another loop inside the while?
-
Try this...
function getReasons ($id) { global $link; $result=''; $rst = mysql_query('SELECT r.name as reason FROM entries_feedback_comments as f LEFT JOIN reasons as r ON r.id = f.reason_id WHERE f.feedback_id ='. $id, $link); while ($row = mysql_fetch_assoc($rst)) { $result.=$row['reason']; } return $result; }
Brilliant!! that worked perfectly. thank you so much for the help and quick responce.
+ i shall remember to wrap my code in the future!
-
Hi all!
First off, sorry if this question is a completely dumb one but i'm really new to PHP.
I'll paste the code to start with...
function getReasons ($id)
{
global $link;
$rst = mysql_query('SELECT r.name as reason FROM entries_feedback_comments as f LEFT JOIN reasons as r ON r.id = f.reason_id WHERE f.feedback_id ='. $id, $link);
while ($row = mysql_fetch_assoc($rst))
{
echo $row['reason'];
}
}
later on in the code.... inside a table structure i do this...
echo '<tr class="' . ($y?'even':'odd') . '">';
echo '<td colspan="10" class="freetext">'.getReasons($row['id']).'</td>';
echo '</tr>';
echo '<tr class="' . ($y?'even':'odd') . '">';
echo '<td colspan="10" class="freetext">'.$row["freetype"].'</td>';
echo '</tr>';
(I have left put the "freetype" bit of code in to show you that it works with this row but not with the function).
Basically, what I see is the result of the function outside of the table itself rather than in the table row.
Is there a reason for this? Does a function have to be put in specific places in the code?
Thank you for your help.
Sam
Calling Function In Table Row
in PHP Coding Help
Posted
brilliant! i did this before:
didnt work because i didnt use the "trim" bit.
thanks again