Jump to content

Recommended Posts

$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:

 

73jur6.png

 

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.. ?

Link to comment
https://forums.phpfreaks.com/topic/164319-why-is-this-only-spitting-out-1-line/
Share on other sites

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

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..

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?

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.