Jump to content

Passing $var in url help please...


rkomar

Recommended Posts

;D

 

Hello,

 

This url worked with globals on and I am want to get this all to work in globals off.

 

Please give me an idea on how to pass this var in the url

 

<a href="/directory/file.php?JobID=<?php echo $JobID ?>">

 

I can not get it to pass a the var with globals off....

 

Any help appreciated.

Reply

Link to comment
Share on other sites

 

This is the whole statement..  ??? Don't know if that makes a diff..

 

<?

while($myrow = mysql_fetch_array($result))

{

$rows++;

if(is_integer($color/2)) {

?> <tr BGCOLOR=#cococo> <?

}

else {

?> <tr BGCOLOR=#ffffff> <?

}

$color++;

$JobID = $myrow["JobID"];

$Date1 = $myrow["Date1"];

$PositionTitle = $myrow["PositionTitle"];

$JobCity = $myrow["JobCity"];

$JobState = $myrow["JobState"];

$Date2 = $myrow["Date2"];

 

 

 

?>

 

<td width="20%" ><p align="left"><font color="000099"><? echo $Date1; ?></font></p></td>

<td width="30%"> <p align="left"><a href="/directory/myfile.php?JobID=<?=$_GET['JobID'] ?>"> <font color="000099"> <?php echo $PositionTitle ?></a> </font> </p></td>

<td width="25%" ><p align="left"><font color="000099"><? echo $JobCity; ?></font></p></td>

<td width="5%"><p align="left"><font color="000099"><? echo $JobState; ?></font></p></td>

<td width="20%"><p align="right"><font color="000099"><? echo $Date2 ?></font></p></td>

</tr>

<?

}

 

mysql_free_result($result);

mysql_close();

?>

Link to comment
Share on other sites

You would have thought that would have worked.... I did't..

 

Does is make a different if the globals are on or off with this code:

 

<a href="/directory/myfile.php?JobID=<?=$_GET['JobID']; ?>">

 

This is not working and quit confusing as to why it is not...

 

Thanks to all who have looked... ???

Link to comment
Share on other sites

actually I think you are confused.  You seem to be trying to use the query string before you get it.  That Get part needs to be done on the myfile.php file you are calling, not on the page that is setting up the link.  YOu can't use it until you push it to the next page.

 

glenn

Link to comment
Share on other sites

Didi you try <a href="/directory/file.php?JobID=[var.JobID]"> ?  That seems to work in some of the scripts I've seen.

 

Yes I just tried that one and it will not work either...

 

So as cybercrypt13 said "I am confused"

 

Right now this is the only thing that works;;

 

<a href="/directory/myfile.php?JobID=<?php echo $JobID ?>">

Link to comment
Share on other sites

but that would be the only thing that works.  I'm not following where your problem is.  lets start over...

 

1) where is $JobID coming from?  It can only be a $_GET if a previous page (not the one you are on but the one before it) pushed it to you.  You are trying to push it to yet another page so I'm assuming you got the var from the previous page and are trying to push it off to the next.  If this is not the case then it will not work.

 

2) If in fact the $JobID came from the previous page and you can echo it then what you're doing will work.  However,  the fact that you say echo $JobID works, I suspect you are not in fact pushing that var from the previous page and you think you are going to use something that hasn't moved yet.

 

So yes, one of us is very confused... :-)

 

 

 

Link to comment
Share on other sites

Actually the previous page pushed the type of position and on the myfile.php page I have this:

 

<?

$conn = mysql_connect("myhost", "myusernane", "mypassword");

mysql_select_db("mydatabase",$conn);

$sql = "SELECT DATE_FORMAT(DatePosted,'%m/%d/%y') AS Date1, DATE_FORMAT(ClosingDate,'%m/%d/%y') AS Date2, JobID, DatePosted, PositionTitle, JobCity, JobState, ClosingDate FROM jobs WHERE PositionType = '" . mysql_real_escape_string($_GET['PositionType']) . "' Order by JobState, JobCity ";

$result = mysql_query($sql);

?>

 

Then comes this - that lists the jobs and there in lays the url for the next link (myfile.php which gives more information on the choosen job....

 

<?

while($myrow = mysql_fetch_array($result))

{

$rows++;

if(is_integer($color/2)) {

?> <tr BGCOLOR=#cococo> <?

}

else {

?> <tr BGCOLOR=#ffffff> <?

}

$color++;

$JobID = $myrow["JobID"];

$Date1 = $myrow["Date1"];

$PositionTitle = $myrow["PositionTitle"];

$JobCity = $myrow["JobCity"];

$JobState = $myrow["JobState"];

$Date2 = $myrow["Date2"];

 

 

 

?>

 

<td width="20%" ><p align="left"><font color="000099"><? echo $Date1; ?></font></p></td>

<td width="30%"> <p align="left"><a href="/directory/myfile.php?JobID=<?php echo $JobID ?>"> <font color="000099"> <?php echo $PositionTitle ?></a> </font> </p></td>

<td width="25%" ><p align="left"><font color="000099"><? echo $JobCity; ?></font></p></td>

<td width="5%"><p align="left"><font color="000099"><? echo $JobState; ?></font></p></td>

<td width="20%"><p align="right"><font color="000099"><? echo $Date2 ?></font></p></td>

</tr>

<?

}

 

mysql_free_result($result);

mysql_close();

?>

 

Link to comment
Share on other sites

<a href="/directory/file.php?JobID=<?=$_GET['JobID'] ?>">

 

You do realize that the <?= was depreciated right? The correct way is the only way that works, fancy that.

 

<a href="/directory/file.php?JobID=<?php echo $_GET['JobID'] ?>">

 

Is the correct way and that is why it works.

 

Stop trying to get the depreciated method to work and just be happy that a method works. Sheesh!

 

 

Link to comment
Share on other sites

You seem to be missing a ; in your code.

 

<td width="20%"><p align="right"><font color="000099"><? echo $Date2; ?></font></p></td>

 

And you closed an <a href=" "> with a [/url].  It should be "</a>".

 

EDIT:  Apparently you can't use < slash a> in post.

Link to comment
Share on other sites

You seem to be missing a ; in your code.

 

<td width="20%"><p align="right"><font color="000099"><? echo $Date2; ?></font></p></td>

 

And you closed an <a href=" "> with a [/url].  It should be "</a>".

 

EDIT:  Apparently you can't use < slash a> in post.

 

Thats what the [ code ] tags are for.

 

Thanks for you input frost110.

 

Oh.. abtw.. it does work.. imagine that..

 

 

 

If it does work I wouldn't code for it, in a year or two when you are updated to PHP 5 those tags will no longer work and your script is toast.

Link to comment
Share on other sites

I know you won't mind if I take my problem to another board.

 

I am just looking for some help with an old php code and trying to update it before moving it onto a newer server and hence a newer version of php/mysql.

 

I really did not mean to turn this into a debate.

 

Thanks to all that sincerely helped.

 

:)

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.