DESCRIPTION METHOD ON SMARTY AND PHP FOR INFORMATION EXTRACTION AT SITE UTILIZING MYSql, PHP AND SMARTY

Asked 1 years ago, Updated 1 years ago, 46 views

Thank you for your help.Please let me know.

We create sites using Mysql, php, and smarty.On the page (smarty) to be displayed for each Proudct_id, I would like to use the table tbl_product_check below to extract the checker_name with the same product_id on the small side.

For example, I would like to see 533 (zen, joy, john) on the smarty side on the page with product_id 533, 514 (james, zen, joy) on the smarty side on the page with product_id 514 and 532 (zen, joy) on the same page. Could you describe how to do it in smarty and php?

*tbl_product_check

(field name)
product_checker_id
product_id
checker_name
member_id

0533zen190    
        1514 james 189   
        2533joice191   
        3532zen 190        
        4514zen190        
        5532joice191   
        6514joice191   
        7533 john192   

add
Dear Himakuma,

We have tried many things, but we have come to the following description using the description method of this framework.However, it is not functioning (there is no error, but nothing is displayed).Could you please point out where the problem is?

PHP:

$objFormParam=new SC_FormParam_Ex();
    $product_id = $objFormParam->getValue('product_id');
    $objQuery=&SC_Query_Ex::getSingletonInstance();
    $checkerName=$objQuery->getOne('SELECT checker_name FROM tbl_product_check where product_id=?', array($product_id)); 
    $results=array();
        foreach($checkerName as$id){
            $results[$id['product_id']][]=$id['product_id'];
        }
        return$results;

SMARTY:

 {foreach from=$checkerNameitem=product_id name=checker_name}
    {$checkerName[$checker_name]}
{/foreach}  

php mysql smarty

2022-09-29 22:48

1 Answers

I don't have enough information, so it's just a rough flow...
1. Get and edit the data you want to display in PHP
2. Hand over data to Smarty
3. Make it look like it wants to be displayed on the Smarty side (pulldown, etc.)

re It does not include require or error determination.
■PHP

<?php
$smarty=new Smarty();

1. Get and edit the data displayed in PHP
$product_id = $_REQUEST ['product_id'];
$sql="SELECT checker_name, member_id FROM tbl_product_check WHERE product_id={$product_id}";
// Issue SQL with PDO, etc. and edit the results into an array that is easy to use in the receiving smarty, etc.
$hyouziDataList=array(
    0=>array('checker_name'=>'zen', 'member_id'=>190),
    1 = > array ('checker_name' = > 'joice', 'member_id' = > 191),
    2=>array('checker_name'=>'john', 'member_id'=>191)
);


2. Hand over data to Smarty
$smarty->assign('hyouziDataList', $hyouziDataList);

Viewing Templates
$smarty->display('index.tpl');
?>

■Smarty

{foreach from=$hyouziDataList item=hyouziData}
3. Make it look like it wants to be displayed on the Smarty side (pull-down, etc.)
    <li>{$hyouziData.member_id}: {$hyouziData.checker_name}</li>
{/foreach}


2022-09-29 22:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.