Página 1 de 2

Mostrar nueva tabla sql en el index

Publicado: 17 Oct 2011, 01:43
por Makoto
Bueno eh tratado de que aparesca una nueva tabla en el indice (index_body.html y root/index.php)
pero nada u_U

probe con el codigo de board_portal_2
SPOILER_SHOW

Código: Seleccionar todo

// Generate birthday list if required ... / borrowed from index.php 3.0.6
		$birthday_list_idol = $birthday_ahead_list_idol = '';
		if ($config['load_birthdays'] && $config['allow_birthdays'])
		{
			$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
			$cache_days = 7;
			$sql_days = '';
			while ($cache_days > 0)
			{
				$day = getdate(time() + 86400 * $cache_days + $user->timezone + $user->dst - date('Z'));
				$sql_days .= " OR u.idol_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $day['mday'], $day['mon'])) . "%'";
				$cache_days--;
			}

			switch ($db->sql_layer)
			{
				case 'mssql':
				case 'mssql_odbc':
					$order_by = 'u.idol_birthday ASC';
				break;

				default:
					$order_by = 'SUBSTRING(u.idol_birthday FROM 4 FOR 2) ASC, SUBSTRING(u.idol_birthday FROM 1 FOR 2) ASC';
				break;
			}
			$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
			$sql = 'SELECT u.idol_id, u.idolname, u.idol_birthday
				FROM ' . IDOLS_TABLE . ' u
				LEFT JOIN ' . BANLIST_TABLE . " b ON (u.idol_id = b.ban_userid)
				WHERE (b.ban_id IS NULL
						OR b.ban_exclude = 1)
					AND (u.idol_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$sql_days})
					AND u.idol_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
				ORDER BY ' . $order_by;
			$result = $db->sql_query($sql);
			$today = sprintf('%2d-%2d-', $now['mday'], $now['mon']);

			while ($row = $db->sql_fetchrow($result))
			{
				if (substr($row['idol_birthday'], 0, 6) == $today)
				{
					$birthday_list_idol .= '<span style="float:left;"><img src="' . $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/portal_user.png" width="16" height="16" alt="" /></span><span style="float:left; padding-left:5px; padding-top:2px;">' . get_username_string('full', $row['idol_id'], $row['idolname'], $row['idol_colour']) . '</span><span style="float: right;">';
					if ($age = (int) substr($row['idol_birthday'], -4))
					{
						$birthday_list_idol .= ' (' . ($now['year'] - $age) . ')';
					}
					$birthday_list_idol .= '</span><br style="clear: both" />';
				}
				elseif ( 7 > 0)
				{
					$birthday_ahead_list_idol .= '<span style="float:left;"><img src="' . $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/portal_user.png" width="16" height="16" alt="" /></span><span style="float:left; padding-left:5px; padding-top:2px;"><span title="' . format_birthday($row['idol_birthday'], 'd M') . '">' . get_username_string('full', $row['idol_id'], $row['idolname'], $row['idol_colour']) . '</span></span><span style="float: right;">';
					if ($age = (int) substr($row['idol_birthday'], -4))
					{
						$birthday_ahead_list_idol .= ' (' . ($now['year'] - $age) . ')';
					}
					$birthday_ahead_list_idol .= '</span><br style="clear: both" />';
				}
			}
			$db->sql_freeresult($result);
		}
SPOILER_SHOW

Código: Seleccionar todo

 'BIRTHDAY_LIST_IDOL'					=> $birthday_list_idol,
			'BIRTHDAYS_AHEAD_LIST_IDOL'			=> ( 7 ) ? $birthday_ahead_list_idol: '',
			'S_DISPLAY_BIRTHDAY_LIST_IDOL'		=> ($config['load_birthdays']) ? true : false,
			'S_DISPLAY_BIRTHDAY_AHEAD_LIST_IDOL'	=> ( 7 > 0) ? true : false,
y uso esta tabla de sql
SPOILER_SHOW

Código: Seleccionar todo

CREATE TABLE `phpbb_idols` (
  `idol_id` mediumint(8) unsigned NOT NULL auto_increment,
  `idol_type` tinyint(2) NOT NULL default '0',
  `idolname` varchar(255) collate utf8_bin NOT NULL default '',
  `idolname_nick` varchar(255) collate utf8_bin NOT NULL,
  `idolname_kanji` varchar(20) character set ujis collate ujis_bin NOT NULL,
  `idol_birthday` varchar(10) collate utf8_bin NOT NULL default '',
  `idol_profile` varchar(200) collate utf8_bin NOT NULL,
  `idol_agency` varchar(200) collate utf8_bin NOT NULL default '',
  `idol_agency_group` varchar(200) collate utf8_bin NOT NULL default '',
  `idol_type_blood` varchar(10) collate utf8_bin NOT NULL,
  `idol_stature` smallint(4) unsigned NOT NULL,
  `idol_native_city` varchar(200) collate utf8_bin NOT NULL default '',
  PRIMARY KEY  (`idol_id`),
  UNIQUE KEY `idolname` (`idolname`),
  KEY `idol_birthday` (`idol_birthday`),
  KEY `idol_type` (`idol_type`)
) ENGINE=MyISAM AUTO_INCREMENT=156 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
que ya lo he definido en constans.php

y en el index_body.html coloco esto
SPOILER_SHOW

Código: Seleccionar todo

<!-- IF BIRTHDAY_LIST_IDOL -->
			<strong>{L_CONGRATULATIONS}:</strong><br /> {BIRTHDAY_LIST_IDOL}
			<!-- ELSE -->
			{L_NO_BIRTHDAYS}
			<!-- ENDIF -->
			<!-- IF S_DISPLAY_BIRTHDAY_AHEAD_LIST_IDOL -->
				<hr class="dashed" />
				<strong>{L_BIRTHDAYS_AHEAD_IDOL}</strong>
				<br />
				<!-- IF BIRTHDAYS_AHEAD_LIST_IDOL -->
				{BIRTHDAYS_AHEAD_LIST_IDOL}
				<!-- ELSE -->
				{L_NO_BIRTHDAYS_AHEAD}
				<!-- ENDIF -->
			<!-- ENDIF -->

Re: Mostrar nueva tabla sql en el index

Publicado: 17 Oct 2011, 04:13
por Alorse
No entiendo que es lo que quieres hacer...
Que pretendes con ese código...
para que la tabla???

Re: Mostrar nueva tabla sql en el index

Publicado: 17 Oct 2011, 19:26
por Makoto
eso me falto, bueno quiero mostrar los cumpleaños(parecido al de phpbb por defecto) pero de otra tabla en el index
en el board portal funciona normal pero en el index no aparece nada u-u

Re: Mostrar nueva tabla sql en el index

Publicado: 17 Oct 2011, 19:34
por Alorse
Haber si entendí, hiciste un script con una nueva tabla en la base de datos, y ahora quieres mostrar información de esa tabla, lo lograste, pero solo se muestra en el portal y en el index no se muestra. Es así?
Donde esta poniendo el código que nos muestras?

Re: Mostrar nueva tabla sql en el index

Publicado: 17 Oct 2011, 19:39
por Makoto
en el root/index.php y en el index_body.html respectivamente

Re: Mostrar nueva tabla sql en el index

Publicado: 17 Oct 2011, 19:49
por Alorse
Te pido que por favor respondas completo, para saber hacia donde va el problema:
Alorse escribió:Haber si entendí, hiciste un script con una nueva tabla en la base de datos, y ahora quieres mostrar información de esa tabla, lo lograste, pero solo se muestra en el portal y en el index no se muestra. Es así?
???
Makoto escribió:en el root/index.php y en el index_body.html respectivamente
Si solamente editaste esos dos archivos como es que se puede ver en el portal?

Re: Mostrar nueva tabla sql en el index

Publicado: 17 Oct 2011, 19:55
por Makoto
las ediciones ya estaban en el portal solo cambia "u.user_" por "u.idol_" y USERS_TABLE por IDOLS_TABLE
lo que hice es coger dichos codigos del modulo birthday de board portal 2 y colocarlos en el index.php

ya no usare el portal por eso estaba adaptandolo en el index

Re: Mostrar nueva tabla sql en el index

Publicado: 18 Oct 2011, 01:05
por Alorse
Y la tabla en la base de datos tiene algo? porque si esta vacía nada va a mostrar, podemos ver algún intento online de lo que quieres hacer?

Re: Mostrar nueva tabla sql en el index

Publicado: 18 Oct 2011, 01:14
por Makoto
si tengo contenido en la tabla u_u
pero hay celdas que "yo" no pude eliminarlas u_u
backup_1318897321_6dc49f0a05e5206b.sql.gz
(4.87 KiB) Descargado 55 veces
CREATE TABLE `phpbb_idols` (
`idol_id` mediumint(8) unsigned NOT NULL auto_increment,
`idol_type` tinyint(2) NOT NULL default '0',
`idolname` varchar(255) collate utf8_bin NOT NULL default '',
`idolname_nick` varchar(255) collate utf8_bin NOT NULL,
`idolname_kanji` varchar(20) character set ujis collate ujis_bin NOT NULL,
`idol_birthday` varchar(10) collate utf8_bin NOT NULL default '',
`idol_profile` varchar(200) collate utf8_bin NOT NULL,
`idol_agency` varchar(200) collate utf8_bin NOT NULL default '',
`idol_agency_group` varchar(200) collate utf8_bin NOT NULL default '',
`idol_type_blood` varchar(10) collate utf8_bin NOT NULL,
`idol_stature` smallint(4) unsigned NOT NULL,
`idol_native_city` varchar(200) collate utf8_bin NOT NULL default '',
PRIMARY KEY (`idol_id`),
UNIQUE KEY `idolname` (`idolname`),
KEY `idol_birthday` (`idol_birthday`),
KEY `idol_type` (`idol_type`)
) ENGINE=MyISAM AUTO_INCREMENT=156 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Bueno estaba pensando poner algo asi encima de forumlist_body.html
Imagen

Re: Mostrar nueva tabla sql en el index

Publicado: 18 Oct 2011, 01:20
por Alorse
Makoto escribió:pero hay celdas que "yo" no pude eliminarlas u_u
Como que no pudiste, acaso no fuiste tú quien creo la tabla? o es copia de otra tabla?
En el index no muestra absolutamente nada? ni siquiera una tabla vacía o un error?

Re: Mostrar nueva tabla sql en el index

Publicado: 18 Oct 2011, 01:23
por Makoto
Alorse escribió:Como que no pudiste, acaso no fuiste tú quien creo la tabla? o es copia de otra tabla?
En el index no muestra absolutamente nada? ni siquiera una tabla vacía o un error?
la tabla es la misma de phpbb_users u_U

no muestra nada nisiquiera algun error u-u
al colocar

Código: Seleccionar todo

<!-- IF BIRTHDAY_LIST_IDOL -->
			<strong>{L_CONGRATULATIONS}:</strong><br /> {BIRTHDAY_LIST_IDOL}
			<!-- ELSE -->
			{L_NO_BIRTHDAYS}
			<!-- ENDIF -->
			<!-- IF S_DISPLAY_BIRTHDAY_AHEAD_LIST_IDOL -->
				<hr class="dashed" />
				<strong>{L_BIRTHDAYS_AHEAD_IDOL}</strong>
				<br />
				<!-- IF BIRTHDAYS_AHEAD_LIST_IDOL -->
				{BIRTHDAYS_AHEAD_LIST_IDOL}
				<!-- ELSE -->
				{L_NO_BIRTHDAYS_AHEAD}
				<!-- ENDIF -->
			<!-- ENDIF -->
en el index_body.html
solo aparece el mensaje no hay proximos cumpleaños y cuando si cumplen año el dia de "hoy" y dentro de 7 dias)

Re: Mostrar nueva tabla sql en el index

Publicado: 18 Oct 2011, 01:35
por Alorse
ok... dime exactamente en que parte del archivo index.php pusiste el código y que código fue el que pusiste.

Re: Mostrar nueva tabla sql en el index

Publicado: 18 Oct 2011, 01:43
por Makoto
en el index.php

buscar

Código: Seleccionar todo

if ($age = (int) substr($row['user_birthday'], -4))
		{
			$birthday_list .= ' (' . ($now['year'] - $age) . ')';
		}
	}
	$db->sql_freeresult($result);
}
luego agrege

Código: Seleccionar todo

// Generate birthday list if required ... / borrowed from index.php 3.0.6
		$birthday_list_idol = $birthday_ahead_list_idol = '';
		if ($config['load_birthdays'] && $config['allow_birthdays'])
		{
			$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
			$cache_days = 7;
			$sql_days = '';
			while ($cache_days > 0)
			{
				$day = getdate(time() + 86400 * $cache_days + $user->timezone + $user->dst - date('Z'));
				$sql_days .= " OR u.idol_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $day['mday'], $day['mon'])) . "%'";
				$cache_days--;
			}

			switch ($db->sql_layer)
			{
				case 'mssql':
				case 'mssql_odbc':
					$order_by = 'u.idol_birthday ASC';
				break;

				default:
					$order_by = 'SUBSTRING(u.idol_birthday FROM 4 FOR 2) ASC, SUBSTRING(u.idol_birthday FROM 1 FOR 2) ASC';
				break;
			}
			$now = getdate(time() + $user->timezone + $user->dst - date('Z'));
			$sql = 'SELECT u.idol_id, u.idolname, u.idol_birthday
				FROM ' . IDOLS_TABLE . ' u
				LEFT JOIN ' . BANLIST_TABLE . " b ON (u.idol_id = b.ban_userid)
				WHERE (b.ban_id IS NULL
						OR b.ban_exclude = 1)
					AND (u.idol_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', $now['mday'], $now['mon'])) . "%' {$sql_days})
					AND u.idol_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ')
				ORDER BY ' . $order_by;
			$result = $db->sql_query($sql);
			$today = sprintf('%2d-%2d-', $now['mday'], $now['mon']);

			while ($row = $db->sql_fetchrow($result))
			{
				if (substr($row['idol_birthday'], 0, 6) == $today)
				{
					$birthday_list_idol .= '<span style="float:left;"><img src="' . $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/portal_user.png" width="16" height="16" alt="" /></span><span style="float:left; padding-left:5px; padding-top:2px;">' . get_username_string('full', $row['idol_id'], $row['idolname'], $row['idol_colour']) . '</span><span style="float: right;">';
					if ($age = (int) substr($row['idol_birthday'], -4))
					{
						$birthday_list_idol .= ' (' . ($now['year'] - $age) . ')';
					}
					$birthday_list_idol .= '</span><br style="clear: both" />';
				}
				elseif ( 7 > 0)
				{
					$birthday_ahead_list_idol .= '<span style="float:left;"><img src="' . $phpbb_root_path . 'styles/' . $user->theme['theme_path'] . '/theme/images/portal/portal_user.png" width="16" height="16" alt="" /></span><span style="float:left; padding-left:5px; padding-top:2px;"><span title="' . format_birthday($row['idol_birthday'], 'd M') . '">' . get_username_string('full', $row['idol_id'], $row['idolname'], $row['idol_colour']) . '</span></span><span style="float: right;">';
					if ($age = (int) substr($row['idol_birthday'], -4))
					{
						$birthday_ahead_list_idol .= ' (' . ($now['year'] - $age) . ')';
					}
					$birthday_ahead_list_idol .= '</span><br style="clear: both" />';
				}
			}
			$db->sql_freeresult($result);
		}
Busque

Código: Seleccionar todo

'BIRTHDAY_LIST'	=> $birthday_list,
luego agrege

Código: Seleccionar todo

'BIRTHDAY_LIST_IDOL'					=> $birthday_list_idol,
	'BIRTHDAYS_AHEAD_LIST_IDOL'			=> ( 7 ) ? $birthday_ahead_list_idol: '',
	'S_DISPLAY_BIRTHDAY_LIST_IDOL'		=> ($config['load_birthdays']) ? true : false,
	'S_DISPLAY_BIRTHDAY_AHEAD_LIST_IDOL'	=> ( 7 > 0) ? true : false,
mencionar que el cumpleaños de usuario si funciona normal

el archivo index porsiacaso
index.rar
(4.42 KiB) Descargado 62 veces

Re: Mostrar nueva tabla sql en el index

Publicado: 18 Oct 2011, 02:22
por Alorse
Lo acabo de probar con la tabla de usuarios y me funciono correctamente, lo único fue que no me reconoció el método format_birthday() de resto todo bien.

Haz lo siguiente, fijate que la tabla este bien declara en el constants.php, o prueba con la tabla de usuarios haber si te funciona, si ambas cosas están bien, entonces el problema esta en la tabla de idols que creaste.

Re: Mostrar nueva tabla sql en el index

Publicado: 19 Oct 2011, 02:03
por Makoto
em falto ponerte que tambien agrego la funcion

Código: Seleccionar todo

/**
* Format user date for the Birthday block
* Note: this function is used as we already added timezones, etc
*
* borrowed from Upcoming Birthday Mod
* @author: lefty
* changed to work outside session.php by B3P
* @function: format_dateucb
*/ 

function format_birthday($date, $format = false)
{
	global $user;
		$time->time_now	= time();
		$lang_dates		= $user->lang['datetime'];
		$format			= (!$format) ? $time->date_format : $format;

		// Short representation of month in format
		if ((strpos($format, '\M') === false && strpos($format, 'M') !== false) || (strpos($format, '\r') === false && strpos($format, 'r') !== false))
		{
			$lang_dates['May'] = $lang_dates['May_short'];
		}
		unset($lang_dates['May_short']);

	// We need to create a UNIX timestamp for date()
	$day = substr($date, 0, strpos($date, '-'));
	$month = substr($date, (strpos($date, '-')+1), 2);
	$year = substr($date, -4);
	$birthday_time = mktime(0, 0, 0, $month, $day, $year);

	return strtr(@date(str_replace('|', '', $format), $birthday_time), $lang_dates);
}
encima del primer codigo u_u