i know how to build the url, but i dont know how to get a variable from it in another page, for example:
index.php3 builds a url called
http://www.myhost.com/id.php3?id=xx
how can i get the variable id=xx into id.php3
in other words, how can i get a variable embeded in the url to work?
with this id i have to get to show the rest of the row contents
variable embeded in url
Moderator: General Moderators
this is whati wrote but it gives me an T_ENCAPSED_AND_WHITESPACE in the second line, this is not the complete script but it's what matters.
this page calls itself in the second part. so first there is a search query that calls this page, it displays the results with a hyperlink that calls the page back ($PHP_SELF) with and added ?id=xx
basically the part that doesn't work is the first 4 or 5 lines, from if ($id) { to } else {
it won't put
printf("nombre: %s\n <br>", $myrow["autor"]); , because there is no id.
this page calls itself in the second part. so first there is a search query that calls this page, it displays the results with a hyperlink that calls the page back ($PHP_SELF) with and added ?id=xx
basically the part that doesn't work is the first 4 or 5 lines, from if ($id) { to } else {
it won't put
printf("nombre: %s\n <br>", $myrow["autor"]); , because there is no id.
Code: Select all
if ($id) {
$result = mysql_query("SELECT * FROM letras WHERE id = $_GETї'id']");
$myrow = mysql_fetch_array(result,MYSQL_ASSOC) ;
printf("nombre: %s\n <br>", $myrowї"autor"]);
} else {
$result = mysql_query("SELECT * FROM letras WHERE autor = "" . $_POSTї'name'] . """);
if(!$result || !mysql_num_rows($result)) {
echo "<table width="100%" border="0" class='body'><tr><td>Query returned no results.</td></tr></table>";
} else {
print("<table width="100%" border="0" class='body'>");
print("<tr><td>Autor</td><td>Titulo</td><td>ID</td></tr>");
while($myrow = mysql_fetch_array($result, MYSQL_ASSOC)) {
printf("<tr><td><a href="%s?id=%s">%s</a></td><td>%s</td><td>%s</td></tr>\n", $PHP_SELF, $myrowї'id'], $myrowї'autor'], $myrowї'titulo'], $myrowї'id']);
}
echo "</table>";