vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Records from database (https://vborg.vbsupport.ru/showthread.php?t=246381)

Przemoo 07-12-2010 09:18 AM

Records from database
 
Hi.

What code is responsible for displaying all the records from the database / table
Is there any other method than "echo"

Speysider 07-12-2010 02:06 PM

Just use the SELECT query and use $row['(name of row here)'] in a table tag.

Przemoo 07-12-2010 02:25 PM

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

Speysider 07-12-2010 02:31 PM

try a do ... while loop, instead of just a while loop

Przemoo 07-12-2010 02:36 PM

what do u mean exactly ? could u change that for me please ?

BirdOPrey5 07-12-2010 02:50 PM

Quote:

Originally Posted by Przemoo (Post 2068082)
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) ) ; 


Przemoo 07-12-2010 03:11 PM

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 ;/

BirdOPrey5 07-12-2010 03:28 PM

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,

Przemoo 07-12-2010 09:17 PM

could u write an example code for templates ? what code should be there :>

BirdOPrey5 07-12-2010 09:24 PM

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.


All times are GMT. The time now is 06:50 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.01149 seconds
  • Memory Usage 1,755KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete