Skocz do zawartości
"Idzie nowe..." - o zmianach i nie tylko ×
Przeniesienie zakupów z IPS Marketplace / Moving bought items from IPS Marketplace ×

Wyświetlanie wyników z bazy danych


Przejdź do rozwiązania Rozwiązane przez Orri,

Rekomendowane odpowiedzi

Siema.
Edytuje panel gracza na IPB i mam aplikację dotyczącą aukcji - dodajemy aukcje z posiadanych przedmiotów, pojazdów itp

Mam pewien problem ponieważ na liście aukcji wyświetla mi się tylko jedna, ostatnio dodana aukcja a chciałbym aby wyświetlały się np. 10 na pierwszej i kolejnych stronach. W kodzie mam tak.

 

Część pliku: modules_public/panel/market.php

<?php

class public_game_panel_market extends ipsCommand
{
    protected $page = 0;
    protected $per_page = 20;
    
    # CLOSE            1
    # BUY            2
    # OFFER            3
    # END             4

    public function doExecute(ipsRegistry $registry)
    {
        if(!$this->memberData['member_id'])
        {
            $this->registry->output->showError('treść błędy');
        }
        
        
        switch($this->request['do'])
        {
            default:
            case 'list':
                $this->showMarketList();
                break;
            case 'view':
                $this->showMarketDetails();
                break;    
            case 'create':
                $this->showMarketCreate();
                break;    
        }
        
        $this->registry->output->setTitle('Rynek');
        $this->registry->output->addNavigation('Rynek', 'app=game&module=panel&section=market', 'false', 'game_market', 'public');
        $this->registry->output->sendOutput();
        
    }
    
    public function    showMarketList()
    {
        $this->page = isset($this->request['st']) ? intval($this->request['st']) : 0;
        # REDIRECT + CHAR
        if(isset($this->request['t_char']))
        {
            $this->registry->output->silentRedirect('index.php?app=game&module=panel&section=market&do=create&sort='.$this->request['sort'].'&char='.$this->request['t_char'].'');
        }
        
        # WYSWIETLANIE POSTACI
        $this->DB->query('SELECT `char_gid`, `char_uid`, `char_name` FROM end_character WHERE char_gid = '.(int)$this->memberData['member_id'].' AND !(char_block & 1)');
        $this->DB->execute();
        while($data = $this->DB->fetch())
        {
            $data['charname'] = str_replace('_', ' ', $data['char_name']);
            $characterList[] = $data;
        }
        
        #PAGINACJA
        require_once(IPSLib::getAppDir('game').'/sources/classes/gamelib.php');
    
        # WYSWIETLANIE LISTY AUKCJI WZGLÄ?DEM SORTOWANIA
        if($this->request['sort'] == 1)
        {
            #PAGINACJA
            $pages = $this->registry->output->generatePagination( array('totalItems'        => GameLib::countMarketItems(),
            'itemsPerPage'        => $this->per_page,
            'currentStartValue' => $this->page,
            'seoTitle'            => 'false',
            'seoTemplate'        => 'game_market',
            'baseUrl'            => 'app=game&module=panel&section=market&sort='.$this->request['sort'].''
            ));
        
            $this->DB->query('SELECT market_bid, market_uid, market_title, market_sub, market_type, market_extraid, market_price, market_end, char_name, member_id, members_display_name, members_seo_name FROM end_character, end_market, ipb_members WHERE char_uid = market_owner AND member_id = char_gid AND market_type = 1 AND market_status = 0 ORDER BY market_start DESC LIMIT '.$this->page.','.$this->per_page.'');
            $this->DB->execute();
        }
        if($this->request['sort'] == 2)
        {
            #PAGINACJA
            $pages = $this->registry->output->generatePagination( array(
            'totalItems'        => GameLib::countMarketVehicles(),
            'itemsPerPage'        => $this->per_page,
            'currentStartValue' => $this->page,
            'seoTitle'            => 'false',
            'seoTemplate'        => 'game_market',
            'baseUrl'            => 'app=game&module=panel&section=market&sort='.$this->request['sort'].'',
            ));
        
            $this->DB->query('SELECT market_bid, market_uid, market_title, market_sub, market_type, market_extraid, market_price, market_end, char_name, member_id, members_display_name, members_seo_name FROM end_character, end_market, ipb_members WHERE char_uid = market_owner AND member_id = char_gid AND market_type = 2 AND market_status = 0 ORDER BY market_uid DESC LIMIT '.$this->page.','.$this->per_page.'');
            $this->DB->execute();
        }
Odnośnik do komentarza
Udostępnij na innych stronach

# WYSWIETLANIE LISTY AUKCJI WZGLÄ?DEM SORTOWANIA
		if($this->request['sort'] == 1)
		{
			#PAGINACJA
			$pages = $this->registry->output->generatePagination( array('totalItems'		=> GameLib::countMarketItems(),
			'itemsPerPage'		=> $this->per_page,
			'currentStartValue' => $this->page,
			'seoTitle'			=> 'false',
			'seoTemplate'		=> 'game_market',
			'baseUrl'			=> 'app=game&module=panel&section=market&sort='.$this->request['sort'].''
			));
		
			$this->DB->query('SELECT market_bid, market_uid, market_title, market_sub, market_type, market_extraid, market_price, market_end, char_name, member_id, members_display_name, members_seo_name FROM end_characters, end_market, ipb_members WHERE char_uid = market_owner AND member_id = char_gid AND market_type = 1 AND market_status = 0 ORDER BY market_start DESC LIMIT '.$this->page.','.$this->per_page.'');
			$this->DB->execute();
		}

Szablon w stylu:

<if test="game:|:is_array($marketList) and count($marketList)">
					<table class="ipb_table">
						<tbody>
							<tr class="header">
								<th scope="col" width="31%">Nazwa</th>
								<th scope="col" width="20%">Sprzedający</th>
								<th width="18%" scope="col">Kończy się</th>
								<th scope="col">Cena</th>
								<th scope="col">Licytacja od</th>

							</tr>
							<foreach loop="game:$marketList as $data">
							<tr>
								<td><a href="index.php?app=game&module=panel&section=market&do=view&sort={$this->request['sort']}&uid={$data['market_uid']}">{$data['market_title']}</a><br /><span class="desc">{$data['mini_desc']}</span></td>
								<td class="col_f_post">
		
								<a href="{parse url="showuser={$data['member_id']}" template="showuser" seotitle="{$data['members_seo_name']}" base="public"}" class="ipsUserPhotoLink left">{IPSMember::buildProfilePhoto($data['member_id'], 'mini')}</a>

									<ul class="last_post ipsType_small">
										
											<li><span itemprop="name">{$data['char_name']}</span></li>
											<li>
												{IPSMember::makeProfileLink($data['members_display_name'],$data['member_id'])}
											</li>
										
									</ul>
								</td>
								<td>{$data['market_end']}</td>
								<td><a data-tooltip="Cena kup teraz"><span class="ipsTag" style="background: url(public/style_game/auction/kupteraz.png); text-shadow: none;">$ {$data['market_price']}</span></a></td>
								<td>
								<a data-tooltip="Licytacja"><span class="ipsTag" style="text-shadow: none;">
								<if test="game:|:$data['market_bid'] == 0">
									Tylko kup teraz
								<else />
									$ {$data['market_bid']}
								</if>
								</span></a>
								</td>
							</tr>
							</foreach>
							
						
						</tbody>
					</table>
					<else />
					<div class="ipsPad">
						Nie znaleziono żadnych aukcji.
					</div>
				</if>
Odnośnik do komentarza
Udostępnij na innych stronach

Aby wyświetlić więcej niż jeden wynik, musisz użyć pętli. Przypisz sobie wynik zapytania do jakiejś zmiennej, tą zmienną przekaż do szablonów a następnie:

<foreach loop="$variable as $key => $value">
    Tutaj wyświetlasz dane ze zmiennej $value albo $key
</foreach>
Odnośnik do komentarza
Udostępnij na innych stronach

No mam zmienną i nadal wyświetla jeden wynik.

while($data = $this->DB->fetch())
		{
			$data['char_name'] = str_replace('_', ' ', $data['char_name']);
			$data['market_end'] = $this->registry->getClass('class_localization')->getDate($data['market_end'], 'TINY', 0, 1);
			$data['mini_desc'] = IPSText::getTextClass('bbcode')->preDisplayParse($data['market_sub']);
			$marketList[] = $data;
		}
		
		

		
		
		$template = $this->registry->output->getTemplate('game')->gameShowMarket($marketList, $characterList, $pages);
		$this->registry->output->addContent($template);
	}
	
Odnośnik do komentarza
Udostępnij na innych stronach

Już wiem na czym polega problem.

Mam kod:

while($data = $this->DB->fetch())
		{
		
		$data['char_name'] = str_replace('_', ' ', $data['char_name']);
			$data['market_end'] = $this->registry->getClass('class_localization')->getDate($data['market_end'], 'TINY', 0, 1);
			$data['mini_desc'] = IPSText::getTextClass('bbcode')->preDisplayParse($data['market_sub']);
			$marketList[] = $data;

		}

Po usunięciu w nim
 

$data['char_name'] = str_replace('_', ' ', $data['char_name']);
			$data['market_end'] = $this->registry->getClass('class_localization')->getDate($data['market_end'], 'TINY', 0, 1);
			$data['mini_desc'] = IPSText::getTextClass('bbcode')->preDisplayParse($data['market_sub']);

Wyświetlają się aukcje lecz nie wyświetla się poprawnie opis aukcji oraz data zakończenia. Jak go przekształcić żeby działał?

Aktualnie wyglada to tak: http://prntscr.com/b483vy
Powinno tak: http://prntscr.com/b4841h

Odnośnik do komentarza
Udostępnij na innych stronach


$execute = $this->DB->execute();

}

while($data = $this->DB->fetch($execute))

{

$data['char_name'] = str_replace('_', ' ', $data['char_name']);

$data['market_end'] = $this->registry->getClass('class_localization')->getDate($data['market_end'], 'TINY', 0, 1);

$data['mini_desc'] = IPSText::getTextClass('bbcode')->preDisplayParse($data['market_sub']);

$marketList[] = $data;

}

Odnośnik do komentarza
Udostępnij na innych stronach

  • Rozwiązanie

Problem dotyczy tej linijki:
 

$data['mini_desc'] = IPSText::getTextClass('bbcode')->preDisplayParse($data['market_sub']);

Po usunięciu jej wyświetla się kilka wyników lecz nie ma opisu aukcji za które odpowiada powyższy kod. Jak go przekształcić?

Odnośnik do komentarza
Udostępnij na innych stronach

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...

Powiadomienie o plikach cookie

Umieściliśmy na Twoim urządzeniu pliki cookie, aby pomóc Ci usprawnić przeglądanie strony. Możesz dostosować ustawienia plików cookie, w przeciwnym wypadku zakładamy, że wyrażasz na to zgodę.