Tag Archives: dynamic

Create dynamic menu array using php

Questions: I want to create array which follows the format below in order to create a dynamic menu in PHP. $array = [ [‘id’=>1, ‘childs’=>[]], [‘id’=>2, ‘childs’=>[ [‘id’=>5, ‘childs’=>[]], [‘id’=>6, ‘childs’=>[]] ]], [‘id’=>3, ‘childs’=>[ [‘id’=>7, ‘childs’=>[ [‘id’=>8,’childs’=>[ [‘id’=>10,’childs’=>[]] ]] ]] ]], [‘id’=>4, ‘childs’=>[]], ]; Data in SQL id id_parent 1 0 2 0 3 0… Read More »

Dynamic chained select box

Questions: Okay, so I have 2 select boxes on my page, the first with the name “select” with the following options hard-coded: <select name=”select” id=”Testid”> <option value=”Misc”>Misc…</option> <option value=”Stunt”>Stunt</option> <option value=”deathmatches”>Deathmatches</option> <option value=”Car”> Car </option> <option value=”Races”>Races </option> </select> The second select box however (named “deleteTp”) I want to populate with a mysql table depending… Read More »

How to make google search dynamic pages of my site

Questions: I am planning an informational site on php with mysql. I have read about google sitemap and webmaster tools. What i did not understand is will google be able to index dynamic pages of my site using any of these tools. For example if i have URLs like www.domain.com/articles.php?articleid=103 Obviously this page will be… Read More »

Dynamic cart item pricing not working on orders in WooCommerce 3.0+

Questions: I am using WooCommerce 3.0+ and I have set the product price on a certain page. $regular_price = get_post_meta( $_product->id, ‘_regular_price’, true); $buyback_percentage = get_post_meta( $_product->id, ‘_goldpricelive_buy_back’, true); $fixed_amount = get_post_meta( $_product->id, ‘_goldpricelive_fixed_amount’, true); $markedup_price = get_post_meta( $_product->id, ‘_goldpricelive_markup’, true); $buyback_price = ($regular_price – $fixed_amount)/(1 + $markedup_price/100) * (1-$buyback_percentage/100); $_product->set_price($buyback_price); The price is updating… Read More »

How to make dynamic form action address in codeigniter?

Questions: I have a search form on my site, and it looks like this: <form action=”/search/results”> <input type=”text” name=”keyword”> <button type=”submit”> // etc… </form> It gets me into mysite.com/search/results/ page where I process post parameters. Of course, I can use the GET method, and then it will be /search/results?keyword=”some_keyword”, but is it possible to make… Read More »

Creating yii2 dynamic pages with url: www.example.com/pageName

Questions: In my system, users need to have their profile pages. It is requested from me that these pages will be displayed in url like this: www.example.com/John-Doe www.example.com/Mary-Smith How to achieve these URLs in yii2 ? These John-Doe and Mary-Smith can be user usernames or profile names. For example I have field in user table… Read More »

Php dynamic class construction

Questions: I’m trying to avoid the use of eval. I can dynamically instantiate a class like this: class myclass {} $my_class_name = ‘myclass’; $obj = new $myclass(); If the constructor is like follows: class myclass { public function __construct( $argument1, $argument2 ) {} } and i have the values of the arguments in an array,… Read More »