Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-12-2010, 09:18 AM
Przemoo Przemoo is offline
 
Join Date: Jun 2010
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Records from database

Hi.

What code is responsible for displaying all the records from the database / table
Is there any other method than "echo"
Reply With Quote
  #2  
Old 07-12-2010, 02:06 PM
Speysider's Avatar
Speysider Speysider is offline
 
Join Date: Apr 2009
Posts: 1,029
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just use the SELECT query and use $row['(name of row here)'] in a table tag.
Reply With Quote
  #3  
Old 07-12-2010, 02:25 PM
Przemoo Przemoo is offline
 
Join Date: Jun 2010
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what is wrong in that code ?

PHP Code:
<?php 

// ####################### SET PHP ENVIRONMENT ########################### 
error_reporting(E_ALL & ~E_NOTICE); 

// #################### DEFINE IMPORTANT CONSTANTS ####################### 
define('NO_REGISTER_GLOBALS'1); 
define('THIS_SCRIPT''test'); // change this depending on your filename 

// ################### PRE-CACHE TEMPLATES AND DATA ###################### 
// get special phrase groups 
$phrasegroups = array( 

); 

// get special data templates from the datastore 
$specialtemplates = array( 
     
); 

// pre-cache templates used by all actions 
$globaltemplates = array( 
    
'screeny'
); 

// pre-cache templates used by specific actions 
$actiontemplates = array( 

); 

// ######################### REQUIRE BACK-END ############################ 
require_once('./global.php'); 

// ####################################################################### 
// ######################## START MAIN SCRIPT ############################ 
// ####################################################################### 

$navbits = array(); 
$navbits[$parent] = 'Testowa Strona'

$sql $db->query_read ("SELECT * FROM `amx_screenshots` ORDER BY ssid DESC");


while( 
$row $db->fetch_array($sql) )


$x++;

$gracz $row["player_username"]; 
$admin $row["admin_username"]; 
$data $row["screenshot_time"]; 
$mapa $row["map"];
$ip $row["player_authid"]; 

$data date("H:i:s  d.m.Y",$data);
/*
$template->assign_block_vars('screeny', array( 

'ID' => $x+$start,
'GRACZ' => $gracz,
'ADMIN' => $admin, 
'DATA' => $data,
'MAPA' => $mapa, 
'IP' => $ip) 
);*/
}

$navbits construct_navbits($navbits); 
eval(
'$navbar = "' fetch_template('navbar') . '";'); 
eval(
'print_output("' fetch_template('screeny') . '");'); 

?>
it shows me only the last entry in the table instead of all
Reply With Quote
  #4  
Old 07-12-2010, 02:31 PM
Speysider's Avatar
Speysider Speysider is offline
 
Join Date: Apr 2009
Posts: 1,029
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try a do ... while loop, instead of just a while loop
Reply With Quote
  #5  
Old 07-12-2010, 02:36 PM
Przemoo Przemoo is offline
 
Join Date: Jun 2010
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

what do u mean exactly ? could u change that for me please ?
Reply With Quote
  #6  
Old 07-12-2010, 02:50 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Przemoo View Post
what do u mean exactly ? could u change that for me please ?
The do... while loop is below... not sure if it will help personally but this is how you do it.

PHP Code:
do 
{  

$x++; 

$gracz $row["player_username"];  
$admin $row["admin_username"];  
$data $row["screenshot_time"];  
$mapa $row["map"]; 
$ip $row["player_authid"];  

$data date("H:i:s  d.m.Y",$data); 
/* 
$template->assign_block_vars('screeny', array(  

'ID' => $x+$start, 
'GRACZ' => $gracz, 
'ADMIN' => $admin,  
'DATA' => $data, 
'MAPA' => $mapa,  
'IP' => $ip)  
);*/ 
} while( $row $db->fetch_array($sql) ) ; 
Reply With Quote
  #7  
Old 07-12-2010, 03:11 PM
Przemoo Przemoo is offline
 
Join Date: Jun 2010
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

still shows the last entry

i think the problem is here
Code:
$sql = $db->query_read("SELECT * FROM `amx_screenshots` ORDER BY ssid DESC");
but i don't know what exactly ;/
Reply With Quote
  #8  
Old 07-12-2010, 03:28 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why don't you echo x; at some point so you can see how many rows there are supposed to be in the loop, that would help pinpoint the issue... if x=1 then the problem is with the sql, otherwise the sql is probably right,
Reply With Quote
  #9  
Old 07-12-2010, 09:17 PM
Przemoo Przemoo is offline
 
Join Date: Jun 2010
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

could u write an example code for templates ? what code should be there :>
Reply With Quote
  #10  
Old 07-12-2010, 09:24 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

after your while loop just put the line:

echo "<h1>" . $x . "</h1>" ;

That should output the value of x somewhere in a big font, just for debugging purposes, obviously don't run your forum this way. I don't know if $x is available in a template... just put:
<h1>$x</h1>
somewhere in the template and see if anything shows up.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:15 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04429 seconds
  • Memory Usage 2,285KB
  • Queries Executed 14 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete