Forum Moderators: coopster

Message Too Old, No Replies

link in option (form)

         

helenp

1:05 pm on Sep 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi, I have this option in form that takes you to another page:

<option value="<?php print($row["conditions"]);?>"><?php print($row["id_propiedad"]); ?></option>
This is a link that is in the database: "<?php print($row["conditions"]);?>"

This works perfect,
however now I want to do soemthing similar, however the link is not in the database, so I only get the id (nombre) from the database and I add the link manually, however I get error, all kinds of colors lol, and cant see what I am doing wrong.
I am trying to do this:
<option value="<?php print "<a href=ver_casas_alquilar.php?nombre=".$row["nombre"].";>?>"><?php print($row["nombre"]); ?></a></option>

Any help would be aprreciate, think I have tried all, but obviously I have not :)
Thanks,
Helen

penders

2:27 pm on Sep 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I very much doubt that $row["conditions"] (in your first option) actually contains an HTML anchor/link element. Since, as you have found in your 2nd option element, that will not work.

Whatever script is processing your form will be performing the redirect (link) to take you to another page.

If all your links follow the same format... "ver_casas_alquilar.php?nombre=SOMETHING" then you just need to put SOMETHING (ie. $row["nombre"]) in your option value and your form processing script will need to do the rest.

helenp

3:55 pm on Sep 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks Penders,
yes $row["conditions"] does have a link in the database, this is the query that works perfect.
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)"> <option>Please select</option>
<?php
$query = " SELECT id_propiedad, conditions FROM casa order by id_propiedad ";
$result = mysql_query ($query);
while ($row = mysql_fetch_array($result)) {
?>
<option value="<?php print($row["conditions"]);?>"><?php print($row["id_propiedad"]); ?></option>
<?php
}
?>
</select>
This is what I want to do, and now get less errors:
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)"> <option>Please select</option>
<?php
include("conex/conexion.php");
$query = " SELECT nombre FROM Casas_alquilar order by nombre ";
$result = mysql_query ($query);
while ($row = mysql_fetch_array($result)) {
?>
<option value=<?php print '<a href=ver_casas_alquilar.php?nombre='.$row["nombre"].';> ?> > <?php print($row["nombre"]); ?> <?php </a>' ?></option>

<?php
}
?>
</select>

What you say at the end I dont understand what to do. What I done is to put $row["nombre"] in the option twice, the first is to pass the id and the link by the url, the second is to have the name in the option list.
Thanks.
Helen

penders

4:59 pm on Sep 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



yes $row["conditions"] does have a link in the database, this is the query that works perfect.
<select name="menu1" onChange="MM_jumpMenu('parent',this,0)">


If this is the same MM_jumpMenu() function I've seen elsewhere then $row["conditions"] is likely to contain just a URL. By 'link' I thought you meant complete HTML link/anchor element (which is what you are trying to squeeze into your second option element).

If this is the case, then I think you just need to do something like the following for your option element...

<option value="ver_casas_alquilar.php?nombre=<?=$row["nombre"]?>"><?=$row["nombre"]?></option>

helenp

7:18 pm on Sep 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks a lot penders, that worked perfectly