how to pass Url parameter via get

Asked

Viewed 742 times

0

I am having a question regarding passing parameters from one page to another. I have tried it in several ways via get. I can even get the parameter, but not all the parameters I can get. In the example below, I can only get the last id registered in the table...

For example:

Through select, I am listing in menu form, in which I pass the id variable of the database table. When I click on the link it redirects me to the page I determined, however, it only takes the last id registered in the table, even presenting a different url, it does not take the id data referring to this...

The code I’m using is as follows::

prepare('SELECT id, categoria FROM teste ORDER BY categoria ASC');
$stmt->execute(); 
if($stmt->rowCount() > 0) 
{ 
    while($row=$stmt->fetch(PDO::FETCH_ASSOC))
    { 
        extract($row); $Link = "".$row['categoria'].""; ?>
".$Link.""?>

The other page: "page"

prepare('SELECT * FROM teste WHERE id=" . $_GET["id"]');
if($stmt->rowCount() > 0)  
    while($row=$stmt->fetch(PDO::FETCH_ASSOC)){ // Escreve dados da pessoa } ?>

is that way.

As I said at the beginning, I can only take and view the data of the last id registered in the table. Where is the error?

Can anyone help me with practical examples?

Obs.: I am working the system with Pdo. Since, I thank everyone that in some way can help me to solve this issue. htaccess is configured like this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php

I’ve tried other settings on htaccess, but the problem persists.

1 answer

0

Yes. I decided to make changes.

To call the other page, I put so too:

<a href="detalhe.php?id=<?php echo $id; ?><?php echo $id; ?></a>

But it did not solve the problem. The data is passed by the url, but only get only one id, in case the last entered in the table.

And on the page that will receive the data I left so:

<?php

    $stmt = $DB_con->prepare('SELECT * FROM produtos WHERE id:$_GET["id"]');

    if($stmt->rowCount() > 0)


    while($row=$stmt->fetch(PDO::FETCH_ASSOC)){

        // Escreve dados da pessoa

    }


?>

...

The error continues.

So far I haven’t been able to solve the problem.

Note: I can pass the codes of the two pages if you want, to see if you can see where the error is.

  • Okay, put it on. Me and the others can take a look

  • Please show the code of the pages, there seem to be some syntax errors.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.