This topic is locked

Smarty problem in list page

7/30/2008 10:08:17 AM
PHPRunner General questions
L
lordkain2 author

Hi, I use this code to show the name of the office instead the id (List Page: Before Display), and it doesn't work, but I can display the name of the office using ECHO.

$var = $_SESSION["Ofi"];
global $conn;

$str = "select Nombre from ofic where Id_Ofic=".$var;

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
echo $data["Nombre"];
$smarty->assign("Id_Ofi",$data["Nombre"]);


Please help me

D
Dale 7/30/2008

Your line
$smarty->assign("Id_Ofi",$data["Nombre"]);[/code]
should it not be
$smarty->assign("Id_Ofic",$data["Nombre"]);[/code]
Most times its something like that that breaks things.

Just a quick stab at it.

Hi, I use this code to show the name of the office instead the id (List Page: Before Display), and it doesn't work, but I can display the name of the office using ECHO.


$var = $_SESSION["Ofi"];
global $conn;

$str = "select Nombre from ofic where Id_Ofic=".$var;

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
echo $data["Nombre"];
$smarty->assign("Id_Ofi",$data["Nombre"]);


Please help me

L
lordkain2 author 7/31/2008

No, Id_Ofic is a field from other table, look the SQL:
SELECT

Estacion,

Fecha,

Notas,

`uid`,

Hora,

Id_Ofi,

Id_Alm

FROM almuerzos
I just want to display the office name instead the Id_Ofi.
Thanks anyways DaleM.

Alexey admin 7/31/2008

Hi,
please where exactly you need to display the value selected in the event.

L
lordkain2 author 7/31/2008

In List page, I use a default value for "Id_Ofi" ($_SESSION["Ofi"]) but I want to display "Nombre".
In Add page I did that using this code:

$var = $smarty->get_template_vars("value_Id_Ofi");

global $conn;

$str = "select Nombre from ofic where Id_Ofic=".$var;

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
global $readonlyfields;

$readonlyfields["Id_Ofi"] = $data["Nombre"];


Now I want to do the same in list page.
Thanks

J
Jane 8/1/2008

Hi,
use custom format on the "View as" settings dialog on the Visual Editor tab for this purpose.

Here is a sample:

global $conn;

if ($value)

{

$str = "select Nombre from ofic where Id_Ofic=".$value;

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
$value = $data["Nombre"];

}