Forum Replies Created

Viewing 15 replies - 31 through 45 (of 72 total)
  • Thread Starter willy70

    (@willy70)

    Dear bcworkz ,
    My script works fine ! I see values selected with form !!!!
    Now I do the checks to sanitize the data and then I have to try to see the results of the query inserted within the “if (‘POST’ == $ _SERVER [‘REQUEST_METHOD’])” opening a new tab.
    Thanks so much for everything !!!
    Best Regards
    Willy

    Thread Starter willy70

    (@willy70)

    Dear bcworkz,
    with your suggestions now this program works fine and as you can
    imagine I had some problems with close routine and others special
    charecters ‘ ” :

    <?php
    /**
     * Template Name: GrandPrix Template
     *
     * Description: A Page Template that adds a sidebar to pages.
     *
     * @package WordPress
     * @subpackage Twenty_Eleven
     * @since Twenty Eleven 1.0
     */
    
    get_header(); 
    
    global $wpdb;
    
    // carica tutte le gare del GrandPrix
    $gare_2016 = $wpdb->get_results("SELECT id,nome,luogo,data FROM ".$wpdb->prefix."gpaltvt_gare WHERE data like '2016%' order 
    by data");
    $gare_2017 = $wpdb->get_results("SELECT id,nome,luogo,data FROM ".$wpdb->prefix."gpaltvt_gare WHERE data like '2017%' order 
    by data");
    
    $anni = $wpdb->get_results("SELECT DISTINCT(date_format(<code>data</code>, '%Y')) AS id FROM ".$wpdb->prefix."gpaltvt_gare order by id"
    ); 
    
    echo '<script  type="text/javascript">';
    echo "	function populate(s1,s2){";
    echo "		var s1 = document.getElementById(s1);";
    echo "		var s2 = document.getElementById(s2);";
    echo "		s2.innerHTML = ''; ";
    echo "		if( s1.value == 2016 ){";
    echo "                  var optionArray = [";
    			foreach ( $gare_2016 as $gara ) {
    				echo chr(34);echo $gara->id;echo chr(124);echo $gara->nome; echo chr(34); 
    			}
    echo "                  ];"; 
    echo "		} ";
    echo "            else if(s1.value == 2017 ){  var optionArray = [";
    			foreach ( $gare_2017 as $gara ) { 
    				echo chr(34);echo $gara->id;echo chr(124);echo $gara->nome;echo chr(34);echo chr(44);
    			}
    echo "                  ];";
    echo "          }";
    echo "		for (var option in optionArray){ ";
    echo "			var pair = optionArray[option].split('|'); ";
    echo "			var newOption = document.createElement('option'); ";
    echo "			newOption.value = pair[0]; ";
    echo "			newOption.innerHTML = pair[1]; ";
    echo "			s2.options.add(newOption); ";
    echo "		}";
    //
    echo "	}";
    echo "</script>";
    // ----  DIV  ---
    echo "                <div id=\"primary\"> ";
    echo "                        <div id=\"content\" role=\"main\"> ";
    echo '<form method="post" action="" >';
    echo "	<h2>Visualizza Classifica. Anno: ";
    echo "	<select id=slct1 name=slct1 onchange=populate(this.id,'slct2')> ";
    echo '	<option value=””></option> ';
    foreach ($anni as $anno)
    	{
    		$year=$anno->id;
    		// “<option value=".$year.">".$year."</option> ” ;
    		$optionh="<option value=";
    		$optionm=">";
    		$optiont="</option>";
    		$optionf=$optionh.$year.$optionm.$year.$optiont ;	
    		echo "$optionf";
    	}
    echo "</select>";
    echo "Gara:";
    echo "<select id=slct2 name=slct2></select>";
    echo "</form>";
    echo "<hr />";
    echo "			</div><!-- #content -->";
    echo "		</div><!-- #primary -->";
    get_footer(); 
    ?>
    

    Now I’ve fix them but to produce the final result I must run
    an sql query and I’d like introduce a “RETURN” button to run
    this query. The results obtaining from wpdb must to be show
    inside this page.

    Your new help would be really appreciated !
    Many thanks for everythings !!!

    Best Regards
    Willy

    Thread Starter willy70

    (@willy70)

    Der Friend,
    your suggestion is correct and professional so I’ve decided to follow you but
    if you have more time for this case I’d like to tell my new problem.

    As you suggested I’ve created a new page template for Twentyeleven theme.
    To make this new template I’ve copied a php file , sidebar-page.php , and
    after that I made some changes.

    First I inserted a new name keeping the same scheme:

    <?php
    /**
    * Template Name: GrandPrix Template
    *
    * Description: My custom pages.
    *
    * @package WordPress
    * @subpackage Twenty_Eleven
    * @since Twenty Eleven 1.0
    */
    get_header();

    then I wrote my php original wordpress theme plus div statements. This second
    part of the code have a class for using db, some sql statement and some html
    because I’d like to run all of them in a server side. In this way I can
    make query and produce html form/select with the right values:

    global $wpdb;
    // load all GrandPrix races
    $gare_2016 = $wpdb->get_results(“SELECT id,nome,luogo,data FROM “.$wpdb->prefix.”gpaltvt_gare WHERE data like ‘2016%’ order
    by data”);
    $gare_2017 = $wpdb->get_results(“SELECT id,nome,luogo,data FROM “.$wpdb->prefix.”gpaltvt_gare WHERE data like ‘2017%’ order
    by data”);
    //load all GrandPrix Years
    $anni = $wpdb->get_results(“SELECT DISTINCT(date_format(data, ‘%Y’)) AS id FROM “.$wpdb->prefix.”gpaltvt_gare order by id”
    );
    // start javascript to populate the second select using reltation with slct1
    //
    echo ‘<script type=”text/javascript”>’;
    echo ” function populate(s1,s2){“;
    echo ” var s1 = document.getElementById(s1);”;
    echo ” var s2 = document.getElementById(s2);”;
    echo ‘ s2.innerHTML = “”; ‘;
    echo ” alert(‘prova’);”;
    echo ” if(s1.value == 2016 ){“;
    echo ” var optionArray = [“;
    foreach ( $gare_2016 as $gara ) {
    echo chr(34);echo $gara->id;echo chr(124);echo $gara->nome; echo chr(34);
    }
    echo ” } else if(s1.value == 2017 ){“;
    echo ” var optionArray = [“;
    foreach ( $gare_2017 as $gara ) {
    echo chr(34);echo $gara->id;echo chr(124);echo $gara->nome;echo chr(34);echo chr(44);
    }
    echo ” }”;
    echo ” for (var option in optionArray){ “;
    echo ‘ var pair = optionArray[option].split(“|”); ‘;
    echo ‘ var newOption = document.createElement(“option”); ‘;
    echo ” newOption.value = pair[0]; “;
    echo ” newOption.innerHTML = pair[1]; “;
    echo ” s2.options.add(newOption); “;
    echo ” }”;
    echo ” }”;
    echo “</script>”;
    // —- DIV —
    echo ” <div id=\”primary\”> “;
    echo ” <div id=\”content\” role=\”main\”> “;
    echo ‘<form method=”post” action=”” >’;
    echo ” <h2>Visualizza Classifica. Anno: “;
    echo ” <select id=slct1 name=slct1 onchange=populate(this.id,’slct2′)> “;
    echo ‘ <option value=””></option> ‘;
    foreach ($anni as $anno)
    {
    $year=$anno->id;
    // “<option value=”.$year.”>”.$year.”</option> ” ;
    $optionh=”<option value=”;
    $optionm=”>”;
    $optiont=”</option>”;
    $optionf=$optionh.$year.$optionm.$year.$optiont ;
    echo “$optionf”;
    }
    echo “</select>”;
    echo “Gara:”;
    echo “<select id=slct2 name=slct2></select>”;
    echo “</form>”;
    echo “<hr />”;
    echo ” </div><!– #content –>”;
    echo ” </div><!– #primary –>”;

    get_footer();
    ?>

    The problem is the second select didn’t populate and I don’t hunderstant
    why. Any suggestions ?

    A logical flow of this code is correct or not ?

    Thanks a lot !!
    Best Regards
    Willy

    Thread Starter willy70

    (@willy70)

    Dear All,
    I think bcworkz’s suggestion is right and is the most professional one but
    reading that post I got an idea. Let me explain.

    I would like to avoid adding wordpress elements because unfortunately I am not a programmer and I have difficulty if I have to use complex objects or structures so
    what do you thing about this example:

    <script>
    function showresults(){
    alert (‘test’);
    }
    </script>
    <form name=XXXX action=”” onsubmit=”return showresults()”>

    the idea is to run javsacript routine that is already inside in the same PHP file.
    Now when user clicks on submit show test but I could change alert “….” with my
    sql and foreach statements for showing my array with values.

    Is correct ? Can it works ?

    Many thanks in adavnce for your help !!
    Bet Regards
    Willy

    Thread Starter willy70

    (@willy70)

    Are there someone that help me ?

    Thanks

    Best Regards
    Willy

    Thread Starter willy70

    (@willy70)

    Dear bcworkz,
    I think post to self due to manage data passed through form because I’ve read some articles but I’m not sure about it.
    If you more time for this question I’ll tell you others details.

    I need to create a page (html plus php) for showing two select.
    In the first user choose the year and in the second choose en event,
    after that there is button to confirm all data and run sql query on my
    custom table.

    The result , for example un array , must to be show in a new or in the
    same html page.

    Above I show you my script:
    <?php
    global $wpdb;
    $gare_2016 = $wpdb->get_results(“SELECT id,nome,luogo,data FROM “.$wpdb->prefix.”gpaltvt_gare WHERE data like ‘2016%’ order by data”);
    .. omissis…
    $anni = $wpdb->get_results(“SELECT DISTINCT(date_format(data, ‘%Y’)) AS id FROM “.$wpdb->prefix.”gpaltvt_gare order by id”);
    <!DOCTYPE html>
    <html>
    <head>
    <script>
    function populate(s1,s2){
    var s1 = document.getElementById(s1);
    var s2 = document.getElementById(s2);
    s2.innerHTML = “”;
    if(s1.value == “2016”){
    var optionArray = [<?php foreach ( $gare_2016 as $gara ) { echo chr(34);echo $gara->id;echo chr(124);echo $gara->nome;
    echo chr(34); } ?> ];
    } else if(s1.value == “2017”){
    var optionArray = [<?php foreach ( $gare_2017 as $gara ) { echo chr(34);echo $gara->id;echo chr(124);echo $gara->nome;
    echo chr(34);echo chr(44); } ?>];
    }
    for(var option in optionArray){
    var pair = optionArray[option].split(“|”);
    var newOption = document.createElement(“option”);
    newOption.value = pair[0];
    newOption.innerHTML = pair[1];
    s2.options.add(newOption);
    }
    }
    </script>
    </head>
    <body>
    <h2>Visualizza Classifica. Anno:
    <select id=”slct1″ name=”slct1″ onchange=”populate(this.id,’slct2′)”>
    <option value=””></option>
    <?php
    foreach ($anni as $anno)
    {
    $year=$anno->id;
    echo “<option value=”.$year.”>”.$year.”</option>”;
    }
    ?>
    </select>
    Gara:
    <select id=”slct2″ name=”slct2″></select>
    <input type=”submit” name=”submit” value=”Enter”>
    <hr />
    </body>
    </html>

    I’m not so fluent with PHP and to realize my little project with wp-admin/admin-post.php
    so you help is very very appreciate but think that this page can be used by non-logged users.

    Thank you so much for this suggestion.
    Best Regards

    • This reply was modified 7 years, 2 months ago by willy70.
    • This reply was modified 7 years, 2 months ago by willy70.
    Thread Starter willy70

    (@willy70)

    PLEASE REMOVE THIS POST . WRONG FORUM.
    THANK YOU

    Thread Starter willy70

    (@willy70)

    Dear Andrew,
    my English is bad my apologize!
    If you want to see my website , for a lot of reasons , you must add
    this entry in your /etc/hosts file:

    193.205.222.189 atleticaumbertide.it

    the page is: https://atleticaumbertide.it/grandprixtest/

    This server is up for a few days for debugging purpose in my virtual machine.

    Thanks again

    Best Regards
    Willy

    Thread Starter willy70

    (@willy70)

    Dear Friend,
    of course, these are two capture first is OK but after make a selection
    instead of show the other information I got an error.

    First is OK

    After Choose Year I got this error

    All of my scripts php are in /var/www/html/wp-content/themes/twentyeleven/

    Thanks so much for everything
    Best Regads

    • This reply was modified 7 years, 2 months ago by willy70.
    • This reply was modified 7 years, 2 months ago by willy70.
    • This reply was modified 7 years, 2 months ago by willy70.

    Dear hansielouw
    your page with results is very nice, in particular reverse date order and
    summarization by race. Can you tell me which is the
    wp-athlethes shortcode to make this ouput ?

    Thanks a lot !
    Best REgards
    Willy

    Thread Starter willy70

    (@willy70)

    Dear Sunny,
    are there any news about this issue ? How Can I read the status of this ticket ?
    Thanks a lot
    Best Regards
    Willy

    • This reply was modified 7 years, 4 months ago by willy70.
    Thread Starter willy70

    (@willy70)

    Hi Sunny
    “Success!
    Support ticket created successfully. Ticket ID reference number: 4750

    I hope about Time.Ly Team has time to investigate this issue.
    Many thanks again.
    Best Regads
    Willy

    yes of course but before send the tar file please check the wp version,
    I use 4.4.8 with twenty eleven theme and wp-athletics 1.1.7.
    I use this old versione of WP because with 4.7.x there are some problems.
    Best Regards
    W.

    Hi,
    I’m using this plugin from december 2015 and as you can see , club records and personal bests are right:
    https://atleticaumbertide.it/record-di-societa/

    if you have time you can search our results here:
    https://atleticaumbertide.it/risultati-recenti/

    it’s seems that are all good, but there are some little bugs
    that I’d fix in the past and most of them were generated from wordpress
    db prefix so be carefull if you havethis scenario.

    Bye
    Willy

    Thread Starter willy70

    (@willy70)

    thanks for this suggestion but I can’t downgrade to 1.1.5 because I’m not sure about
    impact of this operation to data base and other things , so I restore my site to WordPress 4.4 and after that I applied all bug fix up to 4.4.7.
    Best Regards

Viewing 15 replies - 31 through 45 (of 72 total)