Jump to content

Search the Community

Showing results for tags 'twig'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 3 results

  1. Hello I have an array with data from `mysql` that I would like to output it in a table using twig. The image is an example of want i want to achieve but without any luck. `print_r` of the array data Array ( [Administrator] => Array ( [0] => Array ( [RoleName] => Administrator [PermissionName] => Catalog-View [PermissionId] => 1 ) [1] => Array ( [RoleName] => Administrator [PermissionName] => Catalog-Edit [PermissionId] => 2 ) [2] => Array ( [RoleName] => Administrator [PermissionName] => Catalog-Delete [PermissionId] => 3 ) ) [Moderator] => Array ( [0] => Array ( [RoleName] => Moderator [PermissionName] => Catalog-View [PermissionId] => 1 ) ) ) The `HTML` code: <table> <tr> <thead> <th>Controller - Action</th> {% for permission in permissions %} {% for item in permission %} <th>{{item.RoleName}}</th> {% endfor %} {% endfor %} </thead> </tr> {% for permission in permissions %} {% for item in permission %} <tr> <td>{{item.PermissionName}}</td> <td>{{item.PermissionId}}</td> </tr> {% endfor %} {% endfor %} </table> OUTPUT: <table> <tbody> <tr></tr> </tbody> <thead> <tr> <th>Controller - Action</th> <th>Administrator</th> <th>Administrator</th> <th>Administrator</th> <th>Moderator</th> </tr> </thead> <tbody> <tr> <td>Catalog-View</td> <td>1</td> </tr> <tr> <td>Catalog-Edit</td> <td>2</td> </tr> <tr> <td>Catalog-Delete</td> <td>3</td> </tr> <tr> <td>Catalog-View</td> <td>1</td> </tr> </tbody> </table> Later Edit MySQL Query: SELECT t3.PermissionName, t1.PermissionId, t2.RoleName FROM tbl_user_role_perm AS t1 INNER JOIN tbl_user_roles AS t2 ON t1.RoleId = t2.RoleId INNER JOIN tbl_user_permissions AS t3 ON t1.PermissionId = t3.PermissionId MySQL Dump: -- Dumping structure for table tbl_user_permissions CREATE TABLE IF NOT EXISTS `tbl_user_permissions` ( `PermissionId` int(11) NOT NULL AUTO_INCREMENT, `PermissionName` varchar(50) NOT NULL, `PermissionDescription` varchar(100) NOT NULL, PRIMARY KEY (`PermissionId`) ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; -- Dumping data for table tbl_user_permissions: ~2 rows (approximately) DELETE FROM `tbl_user_permissions`; /*!40000 ALTER TABLE `tbl_user_permissions` DISABLE KEYS */; INSERT INTO `tbl_user_permissions` (`PermissionId`, `PermissionName`, `PermissionDescription`) VALUES (1, 'Catalog->View', 'View Catalog Method'), (2, 'Catalog->Edit', 'Edit Catalog Method'), (3, 'Catalog->Delete', 'Delete Catalog Method'); /*!40000 ALTER TABLE `tbl_user_permissions` ENABLE KEYS */; -- Dumping structure for table tbl_user_role CREATE TABLE IF NOT EXISTS `tbl_user_role` ( `UserRoleId` int(10) NOT NULL AUTO_INCREMENT, `UserId` int(10) NOT NULL, `RoleId` int(10) unsigned NOT NULL, PRIMARY KEY (`UserRoleId`), KEY `FK_tbl_user_role_tbl_user_roles` (`RoleId`), KEY `UserId` (`UserId`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; -- Dumping data for table tbl_user_role: ~2 rows (approximately) DELETE FROM `tbl_user_role`; /*!40000 ALTER TABLE `tbl_user_role` DISABLE KEYS */; INSERT INTO `tbl_user_role` (`UserRoleId`, `UserId`, `RoleId`) VALUES (1, 13, 22), (2, 14, 22); /*!40000 ALTER TABLE `tbl_user_role` ENABLE KEYS */; -- Dumping structure for table tbl_user_roles CREATE TABLE IF NOT EXISTS `tbl_user_roles` ( `RoleId` int(10) unsigned NOT NULL AUTO_INCREMENT, `RoleName` varchar(50) NOT NULL, `CreatedDate` datetime NOT NULL, `ModifiedDate` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`RoleId`) ) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8; -- Dumping data for table tbl_user_roles: ~7 rows (approximately) DELETE FROM `tbl_user_roles`; /*!40000 ALTER TABLE `tbl_user_roles` DISABLE KEYS */; INSERT INTO `tbl_user_roles` (`RoleId`, `RoleName`, `CreatedDate`, `ModifiedDate`) VALUES (22, 'Administrator', '2014-10-28 09:53:08', NULL), (23, 'Moderator', '2014-10-28 09:53:13', NULL), (24, 'Admin', '2014-10-28 12:22:05', '2014-10-28 12:22:06'), (25, 'User', '2014-10-29 15:10:36', '2014-10-29 15:10:37'), (26, 'SuperUser', '2014-10-29 15:10:45', '2014-10-29 15:10:46'), (27, 'Accountant', '2014-10-29 15:10:53', '2014-10-29 15:10:54'), (28, 'God', '2014-10-29 15:11:02', '2014-10-29 15:11:02'); /*!40000 ALTER TABLE `tbl_user_roles` ENABLE KEYS */; -- Dumping structure for table tbl_user_role_perm CREATE TABLE IF NOT EXISTS `tbl_user_role_perm` ( `RoleId` int(10) unsigned NOT NULL, `PermissionId` int(10) unsigned NOT NULL, KEY `RoleId` (`RoleId`), KEY `PermissionId` (`PermissionId`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- Dumping data for table tbl_user_role_perm: ~3 rows (approximately) DELETE FROM `tbl_user_role_perm`; /*!40000 ALTER TABLE `tbl_user_role_perm` DISABLE KEYS */; INSERT INTO `tbl_user_role_perm` (`RoleId`, `PermissionId`) VALUES (22, 2), (22, 1), (23, 1), (22, 3); /*!40000 ALTER TABLE `tbl_user_role_perm` ENABLE KEYS */; /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; /*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; Can you help me to make the coding required so that the correct column have the correct permissions? thank you in advance.
  2. I am trying to update the second select box 'subcategory_id' but I don't know how to return the query values back to the control/twig template. All of the examples I have seen echo back html from a option while loop. Should I be echo back the html as per other common examples or is there a more twig compliant way to do this, maybe returning an array variable. Thanks in advance, James catalogues.php <script> $('#category_id').change( function() { checkCategory(); // checks value and enables/disables subcategory control var catid = $(this).val(); var dataString = 'catid='+catid; $.ajax ({ type: "POST", url: "catalogues.php", data: dataString, cache: false, success: function() { $("#subcategory_id")..........; // ????? } }) }); </script> <?php if(isset($_POST['catid'] )) { $catid=$_POST['catid']; $sql_subcategory = "SELECT catalogues_categories.id, catalogues_categories.category, catalogues_categories.parent_id, catalogues_categories.inuse FROM catalogues_categories WHERE catalogues_categories.parent_id = {$catid} AND catalogues_categories.inuse = 1 ORDER BY catalogues_categories.category ASC"; $query_subcategory = $conn->query($sql_subcategory); $results_subcategory = $query_subcategory->fetchAll(); } else { $results_subcategory = null; } ?>
  3. I have a div I use for dialogs and I want to pass a string to the div and then show the specific twig template as an include. The div dialog is displayed without the template embedded, What am I doing wrong, is there a better way to do it? $('#new').click( function() { var str = " {% include 'catalogue_form.html' %} "; $('#dialog').text(str).html(); showDialog(); }); function showDialog() { $('#dialog_wrapper').fadeIn(); $('#dialog').fadeIn("slow"); } Thanks in advance, James
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.