Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
vin_akleh
Forum Commoner
Posts: 53 Joined: Sat Feb 14, 2009 10:26 am
Post
by vin_akleh » Tue Dec 15, 2009 3:33 pm
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
AbraCadaver
DevNet Master
Posts: 2572 Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:
Post
by AbraCadaver » Tue Dec 15, 2009 3:57 pm
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']
mysql_function(): WARNING : This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
vin_akleh
Forum Commoner
Posts: 53 Joined: Sat Feb 14, 2009 10:26 am
Post
by vin_akleh » Tue Dec 15, 2009 4:00 pm
thanks ill try that
vin_akleh
Forum Commoner
Posts: 53 Joined: Sat Feb 14, 2009 10:26 am
Post
by vin_akleh » Tue Dec 15, 2009 5:02 pm
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
!!!!??????
vin_akleh
Forum Commoner
Posts: 53 Joined: Sat Feb 14, 2009 10:26 am
Post
by vin_akleh » Wed Dec 16, 2009 4:23 am
any other sudgestions
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Wed Dec 16, 2009 5:39 am
Can you elaborate on "didn't work".
vin_akleh
Forum Commoner
Posts: 53 Joined: Sat Feb 14, 2009 10:26 am
Post
by vin_akleh » Wed Dec 16, 2009 11:13 am
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
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Wed Dec 16, 2009 12:33 pm
What is the displayed url of the link?
And what does
display?
vin_akleh
Forum Commoner
Posts: 53 Joined: Sat Feb 14, 2009 10:26 am
Post
by vin_akleh » Wed Dec 16, 2009 12:52 pm
jackpf wrote: What is the displayed url of the link?
And what does
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"]."'");??
AbraCadaver
DevNet Master
Posts: 2572 Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:
Post
by AbraCadaver » Wed Dec 16, 2009 1:05 pm
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.
mysql_function(): WARNING : This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
vin_akleh
Forum Commoner
Posts: 53 Joined: Sat Feb 14, 2009 10:26 am
Post
by vin_akleh » Wed Dec 16, 2009 1:15 pm
assume that the variable names are right, is the syntax right??
AbraCadaver
DevNet Master
Posts: 2572 Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:
Post
by AbraCadaver » Wed Dec 16, 2009 1:17 pm
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.
mysql_function(): WARNING : This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Thu Dec 17, 2009 3:37 am
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.
vin_akleh
Forum Commoner
Posts: 53 Joined: Sat Feb 14, 2009 10:26 am
Post
by vin_akleh » Thu Dec 17, 2009 5:13 am
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'].'"
jackpf
DevNet Resident
Posts: 2119 Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK
Post
by jackpf » Thu Dec 17, 2009 5:32 am
That's not the generated url. That's not what shows up in the browser.