Monkuar Posted June 30, 2009 Share Posted June 30, 2009 $DB->query("SELECT * FROM ibf_logs WHERE receiver_id = {$ibforums->member["id"]} && month = '$month' && year = '$year' or sender_id = {$ibforums->member["id"]} && month = '$month' && year = '$year' order by id desc"); if ($DB->get_num_rows()==0) { echo "No Logs for you - I'm fixing this and Working on it. Dont worry, lol."; } else { while ($item = $DB->fetch_row()) { if ($item['sender_id'] == $ibforums->member["id"]){ $grabTwo = ($item[receiver_id] == Store ? "" : mysql_query("SELECT * FROM ibf_members WHERE id = {$item[receiver_id]}")); $getReceiver = ($item[receiver_id] == Store ? "" : mysql_fetch_array($grabTwo)); $nameFrom = "<a href='?showuser={$ibforums->member["id"]}'>" . $ibforums->member["name"] . (isset($ibforums->member["desktop"]) ? "<img src='{$ibforums->member["desktop"]}' </a>" : "</a>"); $nameTo = ($item[receiver_id] == Store ? "Store" : "<a href='?showuser={$getReceiver["id"]}'>" . $getReceiver[name] . (isset($getReceiver[desktop]) ? "<img src='{$getReceiver["desktop"]}'</a>" : "</a>")); } else { $grabThree = mysql_query("SELECT * FROM ibf_members WHERE id = {$item[sender_id]}"); $getSender = mysql_fetch_array($grabThree); $nameFrom = "<a href='?showuser={$getSender["id"]}'>" . $getSender[name] . (isset($getSender[desktop]) ? "<img src='{$getSender["desktop"]}'</a>" : "</a>"); $nameTo = "<a href='?showuser={$ibforums->member["id"]}'>" . $ibforums->member["name"] . (isset($ibforums->member["desktop"]) ? "<img src='{$ibforums->member["desktop"]}'</a>" : "</a>"); } $to = $nameTo; $from = $nameFrom; $amount = $item["amount"]; $time_date = $item["date_time"]; $message = $item["message"]; } } $this->output = $this->html->showlogz($to,$from,$amount,$time_date,$message ); This pulls up data from my MYSQL Forum Gold logs, but it only spits out this 1 line: This is the HTML for it: function showlogz($to,$from,$amount,$time_date,$message) { global $ibforums, $DB; return <<<EOF <fieldset><center><span class=row2><b>Forum Gold Logs</b> <table class='pformstrip' width="100%" border="0" cellspacing="1" cellpadding="4"> <tr> <td colspan="6"> <center> <form name="align_by" method="post" action="?act=logs"> <b>Month / Year:</b> <select name="month" id="month"> <option value='January'>January</option> <option value='February'>February</option> <option value='March'>March</option> <option value='April'>April</option> <option value='May'>May</option> <option value='June'>June</option> <option value='July'>July</option> <option value='August'>August</option> <option value='September'>September</option> <option value='October'>October</option> <option value='November'>November</option> <option value='December'>December</option> </select> 20<input name="year" type="text" maxlength="2" size="2" /> <input type="submit" name="update" id="update" value="Update"> </form> </center> </td> </tr> <tr> <td><b>To</b></td> <td><b>From</b></td> <td><b>Amount</b></td> <td><b>Date and Time</b></td> <td><b>Attached Message</b></td> </tr> <!!RESULTSET> <tr> <td class="row2">$to</td> <td class="row1">$from</td> <td class="row2">$amount <img src="gold3.gif" /></td> <td class="row1">$time_date</td> <td class="row2">$message </td> </tr> <!!/RESULTSET> <!!RESULTSETEMPTY> <tr><td colspan="5" align="center">$nologs</td></tr> <!!/RESULTSETEMPTY> </table> I have alot more Log's then just one.. and there's no "LIMIT" in the SQL.. ?? LOOK: $DB->query("SELECT * FROM ibf_logs WHERE receiver_id = {$ibforums->member["id"]} && month = '$month' && year = '$year' or sender_id = {$ibforums->member["id"]} && month = '$month' && year = '$year' order by id desc"); Were is LIMIT 1? why only spitting out 1 code.. ? Quote Link to comment https://forums.phpfreaks.com/topic/164319-why-is-this-only-spitting-out-1-line/ Share on other sites More sharing options...
RussellReal Posted June 30, 2009 Share Posted June 30, 2009 okay.. your query looks fine, the problem is in the while loop you keep overwriting the same variables.. try this: <?php $DB->query("SELECT * FROM ibf_logs WHERE receiver_id = {$ibforums->member["id"]} && month = '$month' && year = '$year' or sender_id = {$ibforums->member["id"]} && month = '$month' && year = '$year' order by id desc"); if ($DB->get_num_rows()==0) { echo "No Logs for you - I'm fixing this and Working on it. Dont worry, lol."; } else { while ($item = $DB->fetch_row()) { if ($item['sender_id'] == $ibforums->member["id"]){ $grabTwo = ($item[receiver_id] == Store ? "" : mysql_query("SELECT * FROM ibf_members WHERE id = {$item[receiver_id]}")); $getReceiver = ($item[receiver_id] == Store ? "" : mysql_fetch_array($grabTwo)); $nameFrom = "<a href='?showuser={$ibforums->member["id"]}'>" . $ibforums->member["name"] . (isset($ibforums->member["desktop"]) ? "<img src='{$ibforums->member["desktop"]}' </a>" : "</a>"); $nameTo = ($item[receiver_id] == Store ? "Store" : "<a href='?showuser={$getReceiver["id"]}'>" . $getReceiver[name] . (isset($getReceiver[desktop]) ? "<img src='{$getReceiver["desktop"]}'</a>" : "</a>")); } else { $grabThree = mysql_query("SELECT * FROM ibf_members WHERE id = {$item[sender_id]}"); $getSender = mysql_fetch_array($grabThree); $nameFrom = "<a href='?showuser={$getSender["id"]}'>" . $getSender[name] . (isset($getSender[desktop]) ? "<img src='{$getSender["desktop"]}'</a>" : "</a>"); $nameTo = "<a href='?showuser={$ibforums->member["id"]}'>" . $ibforums->member["name"] . (isset($ibforums->member["desktop"]) ? "<img src='{$ibforums->member["desktop"]}'</a>" : "</a>"); } $to = $nameTo; $from = $nameFrom; $amount = $item["amount"]; $time_date = $item["date_time"]; $message = $item["message"]; $this->output .= $this->html->showlogz($to,$from,$amount,$time_date,$message ); } } ?> I just moved the showlogz into the while loop and made it append, tell me how much luck you have Quote Link to comment https://forums.phpfreaks.com/topic/164319-why-is-this-only-spitting-out-1-line/#findComment-866791 Share on other sites More sharing options...
Monkuar Posted July 1, 2009 Author Share Posted July 1, 2009 IT just still spits out same thing, thx tho any other help sir ? Quote Link to comment https://forums.phpfreaks.com/topic/164319-why-is-this-only-spitting-out-1-line/#findComment-866942 Share on other sites More sharing options...
Monkuar Posted July 1, 2009 Author Share Posted July 1, 2009 MY query is fine $DB->query("SELECT * FROM ibf_logs WHERE receiver_id = {$ibforums->member["id"]} && month = '$month' && year = '$year' or sender_id = {$ibforums->member["id"]} && month = '$month' && year = '$year' order by id desc"); I dont know what is the problem here.. Quote Link to comment https://forums.phpfreaks.com/topic/164319-why-is-this-only-spitting-out-1-line/#findComment-866989 Share on other sites More sharing options...
Prismatic Posted July 1, 2009 Share Posted July 1, 2009 What's this do? <?php $DB->query("SELECT * FROM ibf_logs WHERE (receiver_id = {$ibforums->member["id"]} AND month = '{$month}' AND year = '{$year}') OR (sender_id = {$ibforums->member["id"]} AND month = '{$month}' AND year = '{$year}') ORDER BY id DESC"); if($DB->get_num_rows()==0) { echo "No Logs for you - I'm fixing this and Working on it. Dont worry, lol."; } else { while($item = $DB->fetch_row()) { if ($item['sender_id'] == $ibforums->member["id"]) { $grabTwo = ($item['receiver_id'] == Store ? "" : mysql_query("SELECT * FROM ibf_members WHERE id = {$item['receiver_id']}")); $getReceiver = ($item['receiver_id'] == Store ? "" : mysql_fetch_array($grabTwo)); $nameFrom = "<a href='?showuser={$ibforums->member["id"]}'>" . $ibforums->member["name"] . (isset($ibforums->member["desktop"]) ? "<img src='{$ibforums->member["desktop"]}' </a>" : "</a>"); $nameTo = ($item['receiver_id'] == Store ? "Store" : "<a href='?showuser={$getReceiver["id"]}'>" . $getReceiver['name'] . (isset($getReceiver['desktop']) ? "<img src='{$getReceiver["desktop"]}'</a>" : "</a>")); } else { $grabThree = mysql_query("SELECT * FROM ibf_members WHERE id = {$item[sender_id]}"); $getSender = mysql_fetch_array($grabThree); $nameFrom = "<a href='?showuser={$getSender["id"]}'>" . $getSender[name] . (isset($getSender[desktop]) ? "<img src='{$getSender["desktop"]}'</a>" : "</a>"); $nameTo = "<a href='?showuser={$ibforums->member["id"]}'>" . $ibforums->member["name"] . (isset($ibforums->member["desktop"]) ? "<img src='{$ibforums->member["desktop"]}'</a>" : "</a>"); } $out[] = array("to" => $nameTo, "from" => $nameFrom, "amount" => $item['amount'], "time_date" => $item['date_time'], "message" => $item['message']); } } foreach($out as $line) $this->output = $this->html->showlogz($line['to'], $line['from'], $line['amount'], $line['time_date'], $line['message']); ?> Also, on these lines "...$grabTwo = ($item['receiver_id'] == Store ? "" : mysql_query("SELECT * FROM ibf_members WHERE id = {$item['receiver_id']}"));..." is Store supposed to be a constant, variable, or string? Quote Link to comment https://forums.phpfreaks.com/topic/164319-why-is-this-only-spitting-out-1-line/#findComment-867025 Share on other sites More sharing options...
Monkuar Posted July 1, 2009 Author Share Posted July 1, 2009 What's this do? <?php $DB->query("SELECT * FROM ibf_logs WHERE (receiver_id = {$ibforums->member["id"]} AND month = '{$month}' AND year = '{$year}') OR (sender_id = {$ibforums->member["id"]} AND month = '{$month}' AND year = '{$year}') ORDER BY id DESC"); if($DB->get_num_rows()==0) { echo "No Logs for you - I'm fixing this and Working on it. Dont worry, lol."; } else { while($item = $DB->fetch_row()) { if ($item['sender_id'] == $ibforums->member["id"]) { $grabTwo = ($item['receiver_id'] == Store ? "" : mysql_query("SELECT * FROM ibf_members WHERE id = {$item['receiver_id']}")); $getReceiver = ($item['receiver_id'] == Store ? "" : mysql_fetch_array($grabTwo)); $nameFrom = "<a href='?showuser={$ibforums->member["id"]}'>" . $ibforums->member["name"] . (isset($ibforums->member["desktop"]) ? "<img src='{$ibforums->member["desktop"]}' </a>" : "</a>"); $nameTo = ($item['receiver_id'] == Store ? "Store" : "<a href='?showuser={$getReceiver["id"]}'>" . $getReceiver['name'] . (isset($getReceiver['desktop']) ? "<img src='{$getReceiver["desktop"]}'</a>" : "</a>")); } else { $grabThree = mysql_query("SELECT * FROM ibf_members WHERE id = {$item[sender_id]}"); $getSender = mysql_fetch_array($grabThree); $nameFrom = "<a href='?showuser={$getSender["id"]}'>" . $getSender[name] . (isset($getSender[desktop]) ? "<img src='{$getSender["desktop"]}'</a>" : "</a>"); $nameTo = "<a href='?showuser={$ibforums->member["id"]}'>" . $ibforums->member["name"] . (isset($ibforums->member["desktop"]) ? "<img src='{$ibforums->member["desktop"]}'</a>" : "</a>"); } $out[] = array("to" => $nameTo, "from" => $nameFrom, "amount" => $item['amount'], "time_date" => $item['date_time'], "message" => $item['message']); } } foreach($out as $line) $this->output = $this->html->showlogz($line['to'], $line['from'], $line['amount'], $line['time_date'], $line['message']); ?> Also, on these lines "...$grabTwo = ($item['receiver_id'] == Store ? "" : mysql_query("SELECT * FROM ibf_members WHERE id = {$item['receiver_id']}"));..." is Store supposed to be a constant, variable, or string? Variable, I think. Lol I put that code in and nothing happended everything works but only still get 1 row, lol so confusing wow.. iuno what's wrong thx tho sir. Quote Link to comment https://forums.phpfreaks.com/topic/164319-why-is-this-only-spitting-out-1-line/#findComment-867030 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.