0

Hi,

(PHP & MYSQL)

I'm looking for some advice whilst creating my image gallery. I'm using the $_GET to bring the variables I need onto a new page, which will give more details about each product.

My gallery works fine and I then have all the details coming onto the details page, which also works fine... but I have decided I would like to also have "UnitCost" for each item, also displaying on the details page.

I have all the variables displaying on the first page and using $_GET works to display them, except Unit cost, which I want to only display on the details page (as it doesn't need to be in the gallery).

My question is this:

Can I use the mysql query to call the UnitCost on the gallery page (not displaying it anywhere) and then use [ $UnitCost= $_GET; ] to get the variable I need? or do I need to either display it on the gallery page first or write a new MySql statement on the details page?

I hope that makes sense. I'm sure you can tell that I'm a learner but I do try to search for answers before I post here asking for help.

many thanks in advance for help/advice given,

2
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by twiss
0

Hi,

The only variable I need on the details page, that is different from the gallery page, is UnitCost, all of the other variables are displayed in both the gallery and in the details page.

What I wondered was, can I use the existing MySql query on the gallery page (where I manage to $_GET all the other variables for the details page) to $_GET the UnitCost, without it being displayed in the gallery page or do I need to make another MySql query on the details page? if so would this be because UnitCost is not echo'd anywhere on the gallery page?

Does this make it clearer?

Thanks

0

What the preferred way IMHO would be is to pass an ID with GET and get the data of that ID, but passing all the data with GET is possible, too.

0

What the preferred way IMHO would be is to pass an ID with GET and get the data of that ID, but passing all the data with GET is possible, too.

I agree with you and I can see why passing the ID with GET and then using the ID to get the other variables I need would be a better idea... and I may change my gallery to suit this as I think it's a better method but if I wanted to use GET to get a variable called in the query on the gallery page but not echo'd onto the gallery page, can I still use GET?

I'm not getting any errors but I'm not getting any values either!

0

Yes, what did you try? Generally, just pass the ID, and select the details of that ID, something like

$ID = mysql_real_escape_string($_GET['ID']);
$sql = "SELECT * FROM `images` WHERE `ID` = '$ID'";
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.