Jump to content

[SOLVED] $_GET problem


herghost

Recommended Posts

Hi all,

 

Have a bit of a problem with a little piece of code, I am not sure if this should be under php or ajax as I am not sure where the problem lies. Basically here is the script:

 

while($row = mysql_fetch_assoc($query))
{
   echo "<center><tr><td style='color:#00F' align='center'>";
   echo "<a href='./pages/stockpage.php?id=";
   echo $row["stock_id"];
   echo "' title='Contact Us' onclick='Modalbox.show(this.href, {title: this.title, width: 600}); return false;'>";
   echo $row['stock_name'];
   echo "</a></td><td align='center'>";
   echo $row['t_val'];
   echo "</td><td align='center'>";
   echo $row['quant'];
   echo "</td><td align='center' style='color:#00F'>";
   echo $row['TotValue'];
   echo "</td><td>buttonhere</td></tr>";
   
   $TotValue += $row['TotValue'];
}

 

All this does is display info from the database, the problem I have is with the link. If I put my mouse over the link before clicking I get the correct url, ie http://localhost/stockluck/pages/stockpage.php?id=0.

 

The link is meant to open in a modalbox ajax popup, this is the code for stockpage is as follows:

<?php
include('../common/dbconnect.php');

$stock_id = $_GET['stock_id'];
$query="SELECT * FROM stocks WHERE stock_id='$stock_id'"
or die(mysql_error());
while($row = mysql_fetch_assoc($query))
{
echo $row['stock_name'];
}
?>

 

However, the value for $stock_id is coming back as undefined. Any ideas what is causing this?

 

Thanks

Link to comment
Share on other sites

Thanks Daniel, missed that one!

 

Unfortunately I am a relative new comer to php and that way of displaying my echo;s makes it simple for me to understand what line is doing what, it also helps me with any errors as I then know what line and relatively short piece of code is causing the error. I am sure as I become more confident in my ability then the code will get easier to read to an outsider :)

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.