Home Why is my id not getting fetched from my url PHP AJAX MYSQL
Reply: 0

Why is my id not getting fetched from my url PHP AJAX MYSQL

user1362
1#
user1362 Published in May 25, 2018, 11:10 am

Im trying to grab the my 'id' from the url to load the page however it doesn't seem to be showing anything. This is what i have in my url

http://localhost/test/product.php?id=21

When i use

$product_query = "SELECT * FROM photo WHERE photo_id = '21'";

it works fine but obviously i want to be able to load any item that is clicked on that has an

from my gallery.php

<a href='product.php<?php echo"?id=$photo_id" ?>'>Get this Product!</a>"

So this is what i have got from researching but still not results

this is my action.php

if(isset($_GET["getProductind"])){

$photo_id = (isset($_GET['id']) ? $_GET['id'] : null);

    $product_query = "SELECT * FROM photo WHERE photo_id = '$photo_id'";
    $run_query = mysqli_query($conn,$product_query);
    if(mysqli_num_rows($run_query) > 0){
        while($row = mysqli_fetch_array($run_query)){

And this is what im using in my ajax script

main.js

function productind(){
$.ajax({
    url :   "action.php",
    method: "GET",
    data    :   {getProductind:1},
    success :   function(data){
        $("#get_productind").html(data);
    }
})
}

Updated hopefully this makes more sense

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.338468 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO