On Aug 9, 2011, at 3:41 PM, Peter Lind wrote:
On 9 August 2011 22:38, Chris Stinemetz <chrisstinemetz@xxxxxxxxx>
wrote:
Yes, debug your code and figure out why it's looping twice instead.
For instance, try the other query in the mysql console.
Thank you! It was the first query. I put a LIMIT 1 on it and now it
is
working correctly. I appreciate your help!
You're fixing the symptom, not the problem. Your query was returning
multiple values because something is wrong with the query or your
data. If you don't correct it, the problem will likely just grow
bigger.
--
<hype>
WWW: plphp.dk / plind.dk
LinkedIn: plind
BeWelcome/Couchsurfing: Fake51
Twitter: kafe15
</hype>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Hi Chris,
Is this what your looking for?
<?php
//store.php
include_once 'includes/connect.php';
include_once 'includes/header.php';
//print("<pre>".print_r($_GET,true)."</pre>"); //Not sure what this is
for, uncomment if needed.
if(!$_SESSION['signed_in']) {//Check to see if signed in first, then
do search, otherwise display and search nothing.
echo('<table class="table1" border="1">
<tr>
<td colspan=2>You must be <a href="signin.php">signed in</a> to
reply. You can also <a href="signup.php">sign up</a> for an account.</
td>
</tr>
</table>');
}
else {
$sql = "SELECT * FROM stores WHERE store_subject =
'".mysql_real_escape_string($_GET['id'])."'";
$result = mysql_query($sql);
//fetch the posts from the database
$posts_sql = "SELECT
stores.store_subject,
stores.store_comments,
stores.store_date,
stores.store_tptest,
stores.store_by,
users.user_id,
users.user_name,
users.first_name,
users.last_name
FROM
stores
LEFT JOIN
users
ON
stores.store_by = users.user_id
WHERE
stores.store_subject = '".mysql_real_escape_string($_GET['id'])."'
ORDER BY
stores.store_date
DESC LIMIT=30";// Set a number of records if you dont want to display
ALL records on one page and want to build in pagination.
if(!$result || mysql_num_rows($result) == 0) {
echo('This store visit doesn′t exist.');
}
else {
echo('<table class="table1" border="1">');
while($row = mysql_fetch_array($result)) {
//display post data
$posts_result = mysql_query($posts_sql);//This may be the culprit
you had. Do you mean to do the $posts_sql query for ever result in
$sql query?? If not, move out of while loop above. Also, can you get
the same result by just using the $posts_sql query and axe the $sql
query?? They look like you get the same results to me. May be redundant.
echo('<tr><td colspan="2">'.$row['store_subject'].'</td></tr>');
if(!$posts_result || mysql_num_rows($posts_result) == 0) {
echo ('<tr><td>No Post results.</td></tr></table>');
} else {
while($posts_row = mysql_fetch_array($posts_result)) {
echo('<tr class="topic-post">
<td class="user-post">'.$posts_row['first_name'].'$nbsp;'.
$posts_row['last_name'].'<br/>'.date('m-d-Y h:iA',
strtotime($posts_row['store_date'])).'</td>
</tr>
<tr><td class="post-content">'.$posts_row['store_tptest'].'<br/
>'.htmlentities(stripslashes($posts_row['store_comments'])).'</td>
</tr>');
}
}
//show reply box
echo('<tr><td colspan="2"><h2>Reply:</h2><br />
<form method="post" action="reply.php?id='.$row['store_id'].'">
<textarea name="reply-content"></textarea><br /><br />
<input type="submit" value="Submit reply" />
</form></td></tr>');
//finish the table
echo('</table>');
}
}
}
include_once 'includes/footer.php';
?>
HTH,
Karl DeSaulniers
Design Drumm
http://designdrumm.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php