简体   繁体   中英

$_GET doesnt work

Hey guys i've a little problem here...

why my $_GET doesnt work...

$_GET[id] or $_GET['id'] both of them not work...

here's my code...

if(isset($_GET['aksi']) && $_GET['aksi'] == 'forminput'){
    $ambilKategoriBarang = mysql_query("select * from kategori_barang");
    echo "<div id='result'>&nbsp;</div>"; // untuk nanti data calllbach hasil request akan di tampilkan disini
    echo "<form id='frm_input'>";
    echo "<table cellpading='1' cellspacing='1' width='100%' border='0'>";
    //pemberian atribut id sangat penting.. karena nilai yang di ambil dari fild tersebut nanti berdasarkan id tersebut
    echo "<tr><td width='30%'>Kode Barang</td><td><input type='text' name='nim' id='nim'></td></tr>";
    echo "<tr><td width='30%'>No PO</td><td><input type='text' name='nopo' id='nopo' value='$_GET[idttb]'></td></tr>";
    echo "<tr><td>Jumlah Diterima</td><td><input type='text' name='nama' id='nama'></td></tr>";
    echo "<tr><td>Kategori Item</td><td><select name='tmplahir' id='tmplahir'>
                            <option value='0'>- Kategori Barang-</option>";
                            while($kategori = mysql_fetch_array($ambilKategoriBarang)){
                                echo "<option value='$kategori[namaKategoriBarang]'>$kategori[namaKategoriBarang]</option>";
                            }
            echo "</select></td></tr>";
    echo "<tr><td>Status</td><td><select name='status' id='status'>
    <option value='Incindentil'>Incindentil</option>
    <option value='Stock'>Stock</option>
    </select></td></tr>";
    echo "<tr><td>&nbsp;</td><td><input type='submit' value='kirim'></td></tr>";
    echo "</table>";
    echo "</form>";
    exit();
}

as you can look..

$_GET['aksi'] <--- works

but why the

$_GET['idttb'] <--- Doesnt work

the url is

127.0.0.1/jualbeli/sistem/modul/mod_input.php?idpo=1&idttb=1

anyone can help me please??

thanks before

============== OK LET ME EXPLAIN IT =============================

Here i have 4 php files.. 1. proses.php 2. mahasiswa.php 3. mod_input.php 4. mod_listpo.php

and here's the source code

Note : there's no "mod_listpo" file because i only use this file to call mod_input.php

function win1() {
    window.open('./modul/mod_input.php?idpo='+ document.getElementById('idpo').value +'&&idttb='+ document.getElementById('idttb').value,'Window1','menubar=no,width=540,height=360,toolbar=no');
}

here's the link code

h t t p s://github.com/dammionx/code1

the flow is like this...

i using the mod_listpo.php to call mod_input.php using that code...

what i exactly want is, the mod_list.php can use $_GET to get the "idpo" and "idttb" value..

anyone can help me??

thanks before

Try this bit of code to see what $_GET contains. It wont neccessarily fix the problem but may help solve it.

<?php
echo "<pre>";
print_r($_GET);
echo "</pre>";
exit();
?>

change

echo "<tr><td width='30%'>No PO</td><td><input type='text' name='nopo' id='nopo' value='$_GET[idttb]'></td></tr>";

to

echo "<tr><td width='30%'>No PO</td><td><input type='text' name='nopo' id='nopo' value='".$_GET['idttb']."'></td></tr>";

尝试

echo "<tr><td width='30%'>No PO</td><td><input type='text' name='nopo' id='nopo' value='". $_GET['idttb'] ."'></td></tr>";

The $_GET[idttb] is within a string in an echo statement. You can't use arrays within strings the same way you can use normal variables. You need to end the string before, use the . operator to concatinate the value of the variable, then use the same again to concatinate the rest of the string.

I hope this helps.

I agree with BvdVen.

I'd like to give more details. Pay attention to simple and double quotes.

Link .

<?php $myvar = $_GET['mygetvar'] ?>
<?php echo 'this number is $_GET[mygetvar]' ?>
<?php echo "this number is " . $_GET['mygetvar'] ?>
<?php echo "this number is  $myvar" ?>
<?php echo 'this number is $myvar' ?>
<?php echo 'this number is ' . $myvar ?>

Results:

this number is $_GET[mygetvar]
this number is 123
this number is 123
this number is $myvar
this number is 123

http://phphowto.blogspot.fr/2006/12/concatenate-strings.html

127.0.0.1/jualbeli/sistem/modul/mod_input.php?idpo=1&&idttb=1

应该是&&而不是&

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM