Page 1 of 1

Href

Posted: Wed Jun 04, 2003 9:20 am
by silgol
The following problem is presented: I Have a board and desire to unfold the data. Then, desire to do a link to another page, click in any element of the same one.
How would be the instruction? (and I refer to the instruction stood out in red color)
mysql_connect("localhost","xx","yy");
$result=mysql_db_query("Publisher","select * from Medios");

echo "<table width=300 align=left border=2 bgcolor='#CCFFFF' cellpadding=1 cellspacing=1 >";
while($row=mysql_fetch_row($result))
{
echo
"<TR><TD>
<a href='sumamedio.php>?$row[1]'.$$row[0]></tr>";
?> </TD>
<?
}
echo"</table>";

Posted: Wed Jun 04, 2003 10:03 am
by grooou
assuming that you want to display $row[0] and pass variable $row[1] to sumamedio.php:

Code: Select all

<?php
// ...
while($row = mysql_fetch_row($result)) {
  echo "<tr><td>";
  echo "<a href='sumamedio.php?id=" . $row[1] . "'>";
  echo $row[0];
  echo "</a>";
  echo "</td></tr>";
}
// ...
?>


in sumamedio.php you can use the $_GET array. Here's one simple example:

Code: Select all

<?php
if (isset($_GET['id'])) {
   $id = $_GET['id'];
} else {
  $id = "";
}


// etc ...

?>

good luck