Page 1 of 2

dynamic form problem???

Posted: Tue Dec 15, 2009 3:33 pm
by vin_akleh
every time i click on any of the 5 images or submit button from
<input type="hidden" name="select" value="'.$url["link"].'" >
gives me the value of select the same value, which is the last value which is the fifth

Code: Select all

<?php
    $qu=mysql_query("select * from lnk order by link desc limit 5");
    while ($url=mysql_fetch_array($qu))
    {
        if ($url['im']=='') 
            $url['im']='images/default.jpg';
        echo '<td><table class=media><tr><td>
            <input type="image" src="'.$url['im'].'" width=150 height= 200/>
            <input type="hidden" name="select" value="'.$url["link"].'" >
            </a></td></tr><tr>';
        if (strlen($url["tit"])>16)
            $url["tit"]=substr($url["tit"],0,16).'...';
    echo '<td><input type="submit" value="'.$url["tit"].'" class="trans2"></td></tr></table></td>';
    }//end while
?>
example: if the last $url["link"] value was 30 then by clicking on any of the images or the submits it will give me the value of

Code: Select all

extract($_POST);
echo ".$select.";
is 30 and not the one i clicked on

Re: dynamic form problem???

Posted: Tue Dec 15, 2009 3:57 pm
by AbraCadaver
Image inputs are submit buttons so they submit the entire form. If you have 10 hidden inputs with the same name "select" then only the last one is populated in the $_POST array. I think I see the direction you're going and it's the wrong direction. You would probably be better off not using a form, but using a regular image and wrapping it in an anchor:

Code: Select all

'<a href="your_script.php?select="'.$url["link"].'">
    <img src="'.$url['im'].'" width="150" height="200" />
</a>' 
Then in your_script.php use the $_GET['select']

Re: dynamic form problem???

Posted: Tue Dec 15, 2009 4:00 pm
by vin_akleh
thanks ill try that

Re: dynamic form problem???

Posted: Tue Dec 15, 2009 5:02 pm
by vin_akleh
i did try it, this

Code: Select all

<a href="selection.php?select=abc"><img src="'.$url['im'].'" width="150" height="200" /></a>';
worked but these didnt

Code: Select all

<a href="selection.php?select="'.$url['link'].'"><img src="'.$url['im'].'" width="150" height="200" /></a>';
<a href="selection.php?select="'.$url['link'].'""><img src="'.$url['im'].'" width="150" height="200" /></a>';
<a href="selection.php?select='.$url['link'].'"><img src="'.$url['im'].'" width="150" height="200" /></a>';
and others
!!!!?????? :?: :!:

Re: dynamic form problem???

Posted: Wed Dec 16, 2009 4:23 am
by vin_akleh
any other sudgestions

Re: dynamic form problem???

Posted: Wed Dec 16, 2009 5:39 am
by jackpf
Can you elaborate on "didn't work".

Re: dynamic form problem???

Posted: Wed Dec 16, 2009 11:13 am
by vin_akleh
jackpf wrote:Can you elaborate on "didn't work".
when i tried to echo select when it was abc, it did echo it
but the other three and more i have tried, didnt echo anything

Re: dynamic form problem???

Posted: Wed Dec 16, 2009 12:33 pm
by jackpf
What is the displayed url of the link?

And what does

Code: Select all

print_r($_GET);
display?

Re: dynamic form problem???

Posted: Wed Dec 16, 2009 12:52 pm
by vin_akleh
jackpf wrote:What is the displayed url of the link?

And what does

Code: Select all

print_r($_GET);
display?
this:

Code: Select all

<a href="selection.php?select="'.$maxurl['image'].'"">
outs:
Array ( [select] => )
this:

Code: Select all

<a href="selection.php?select='.$maxurl['image'].'">
outs:
Array ( [select] => images/default.jpg )
i am guessing that the second one doesn't have any problem, if not
is this any wrong:

Code: Select all

$qu = mysql_query("select * from lin where link like '".$_GET["select"]."'");
?? :?: :?:

Re: dynamic form problem???

Posted: Wed Dec 16, 2009 1:05 pm
by AbraCadaver
Why don't you post your entire code again since it bears no resemblance in var names or anything else to what you posted earlier.

Re: dynamic form problem???

Posted: Wed Dec 16, 2009 1:15 pm
by vin_akleh
assume that the variable names are right, is the syntax right??

Re: dynamic form problem???

Posted: Wed Dec 16, 2009 1:17 pm
by AbraCadaver
vin_akleh wrote:assume that the variable names are right, is the syntax right??
I suppose. Just that if $maxurl['image'] in the link doesn't contain a value, then $_GET['select'] on the next page won't either.

Re: dynamic form problem???

Posted: Thu Dec 17, 2009 3:37 am
by jackpf
I meant what is generated, not the code generating it.

Just wondering why on one of the links you have two double quotes at the end.

Re: dynamic form problem???

Posted: Thu Dec 17, 2009 5:13 am
by vin_akleh
jackpf wrote:I meant what is generated, not the code generating it.

Just wondering why on one of the links you have two double quotes at the end.
this one:

Code: Select all

1.<a href="selection.php?select="'.$maxurl['image'].'"">
one for the href and the other is for the "'.$maxurl['image'].'"

Re: dynamic form problem???

Posted: Thu Dec 17, 2009 5:32 am
by jackpf
That's not the generated url. That's not what shows up in the browser.