Href

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
silgol
Forum Newbie
Posts: 11
Joined: Fri Jan 24, 2003 1:31 pm

Href

Post 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>";
User avatar
grooou
Forum Newbie
Posts: 8
Joined: Tue Jun 03, 2003 1:21 pm
Location: Portugal

Post 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
Post Reply