Home News Contact Us Forum About Us Demos Products F.A.Q.
Shopping Cart
You currently have 0 items in your cart.


Recent Events
  • 31/12/2023 New Year SALE

    We are glad to announce New Year SALE. 25% discount for all our extensions. Use NY24 coupon code. Hurry up the discount is valid till 7 January.

  • 21/11/2023 BLACK FRIDAY 23 is coming

    BIG SALE, 35% discount for all our extensions. Use BF23 coupon code. Hurry up the discount is valid till 27 November.


2Checkout.com, Inc. is an authorized retailer of goods and services provided by ARI Soft. 2CheckOut




Follow us on twitter



Welcome, Guest
Please Login or Register.    Lost Password?

help query from form input variable
(1 viewing) (1) Guest
Go to bottomPage: 123
TOPIC: help query from form input variable
#32490
help query from form input variable 11 Years, 7 Months ago Karma: 0
hai there,
please someone help me, i'm not really good on coding.
is there a way i can send form variable to the sql query on the module.
i mean is i want user to be able to select what month and year of data they want to view and do it using form month and year dropdown menu i made, they submit the request and the tables comeup with the result.
i have this for the form, but i wonder how and where to put it

Code:


<h1 align="center" >peserta kb aktif</h1>

<form action="tabel.php" method="post">
   Bulan
    <?php
$curr_month = date("m");
$month = array (1=>"Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember");
$select = "<select name=\"bulan\">\n";
foreach ($month as $key => $val) {
    $select .= "\t<option val=\"".$key."\"";
    if ($key == $curr_month) {
        $select .= " selected=\"selected\">".$val."</option>\n";
    } else {
        $select .= ">".$val."</option>\n";
    }
}
$select .= "</select>";
echo $select;
?>
    Tahun
    <select name="tahun">
    <?php
    $mulai= date('Y') - 5;
    for($i = $mulai;$i<$mulai + 20;$i++){
    $sel = $i == date('Y') ? ' selected="selected"' : '';
    echo '<option value="'.$i.'"'.$sel.'>'.$i.'</option>';
    }
    ?>
    </select>
    <input type="submit" value="Kirimkan"/> 
  </form>



on my normal html form i used to capture the value submitted with
Code:


<?php
$bulan=trim(strip_tags($_POST['bulan']));
$tahun=trim(strip_tags($_POST['tahun']));
   ?>



and use that $bulan and $tahun variable on the mysql query.

i really stuck on this, any help will be apreciated.

sorry for my bad english,


regards.
Mo.
The administrator has disabled public write access.
 
#32494
Re:help query from form input variable 11 Years, 7 Months ago Karma: 748
Hello,

According to your code you can use {$REQUEST:bulan} and {$REQUEST:tahun} variables in WHERE clause of a SQL query. Sample SQL query will look like:

Code:


SELECT
 *
FROM
 tbl
WHERE
 month = {$REQUEST:bulan}
 AND
 year > {$REQUEST:tahun}



Regards,
ARI Soft
The administrator has disabled public write access.
 
#32496
Re:help query from form input variable 11 Years, 7 Months ago Karma: 0
hi admin,

thanks for the tips, i'll give it a go
but one more thing is what should i put on the form action?

regards,
Mo.
The administrator has disabled public write access.
 
#32497
Re:help query from form input variable 11 Years, 7 Months ago Karma: 748
Leave "action" attribute empty or put link to the page with the table.

Regards,
ARI Soft
The administrator has disabled public write access.
 
#32498
Re:help query from form input variable 11 Years, 7 Months ago Karma: 0
Thanks admin,

its works like a charm.


and if you don't mind, can you tell me how to add extra collumn and to put script on the row value.

thanks again,
Mo.
The administrator has disabled public write access.
 
#32503
Re:help query from form input variable 11 Years, 7 Months ago Karma: 748
Could you explain in more details what column and what script do you want to add?

Regards,
ARI Soft
The administrator has disabled public write access.
 
Go to topPage: 123