Variable not working under mysqli_num_rows...
Posted: Mon Jul 09, 2007 12:30 am
feyd | Please use
feyd | Please use
Code: Select all
,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]
The variable $question works good if not used within if statement, but it doesn't show the data when used under if (mysqli_num_rows) statement.
can any help me with what I am doing wrong here... please...Code: Select all
$sid = $_GET['sid'];
if (!$resultdisp = @mysqli_query($link, 'SELECT users.username, users.name, tblquestion.id, tblquestion.question, tblreply.* FROM `users`, `tblquestion`, `tblreply` WHERE users.username = tblreply.username AND tblreply.questid = tblquestion.id AND questid = \'' . $sid . '\'')) {
echo getHeader();
echo '<div id=centreall><p>Error: ' . mysqli_error($link) . '.</p></div>';
echo getFooter();
mysqli_close($link);
exit;
}
while ($rowquest = mysqli_fetch_assoc($resultdisp)) {
$question = $rowquest['question'];
}
$row_cnt = mysqli_num_rows($resultdisp);
if (!$row_cnt >0) {
echo getHeader();
echo '<div id=logged><p> You are logged in as <em>' . $_SESSION['valid_user'] . '</em> | <a href=logout.php5>logout</a></p></div>';
echo '<div id=centreall><p>' . $question . '</p></div>'; //<-- THIS ONE NOT SHOWING
echo '<div id=centreall><p> This question haven\'t received any reply yet.</p></div>';
echo '<p class=nav><a href=admlist.php5>back</a></p>';
echo getFooter();
exit;
}
echo getHeader();
echo '<div id=logged><p> You are logged in as <em>' . $_SESSION['valid_user'] . '</em> | <a href=logout.php5>logout</a></p></div>';
echo '<div id=centreall><p>' . $question . '</p></div>'; //<-- THIS ONE SHOWS
?>
<form>
<div id="admform">
<?php
mysqli_data_seek($resultdisp, 0);
while ($row = mysqli_fetch_assoc($resultdisp)) {
echo '<fieldset>';
echo '<legend>' . $row['name'] . '</legend>';
echo '<p class=repday><i>replied on</i> ' . date('d M Y', strtotime($row['repday'])) . '</p>';
echo '<p class=rep>' . $row['reply'] . '</p>';
echo '<p><i>' . $row['comment'] . '</i></p>';
echo '</fieldset>';
}
mysqli_free_result($resultdisp);
mysqli_close($link);
?>
</div>
</form>
<?php
echo '<p class=nav><a href=admlist.php5>back</a></p>';
echo getFooter();
exit;
}feyd | Please use
Code: Select all
,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]