Page 1 of 1

[SOLVED] fetching id from other page..

Posted: Wed Apr 14, 2004 4:07 pm
by ol4pr0
Clueless ...

Code: Select all

<? echo "<a href="2.php?id=$guia_madre"><img src="../images/b_arrows.png" border="0">$guia_madre</a>


Now on 2.php i need to fetch the quia_madre number so i would know which $guia_madre i need to select ...

How would i do such a thing..

A little hint to get me started would be nice :)

Posted: Wed Apr 14, 2004 4:08 pm
by markl999
$_GET['guia_madre'] ??

Posted: Wed Apr 14, 2004 6:03 pm
by ol4pr0
Without using the $_POST ?

if with $_POST how would i put the post ... if not using a form or action.
with just only the link like discribed as above...

Code: Select all

$query = ("SELECT * FROM tms WHERE guia_madre='$_GET['guia_madre']'");
?

Posted: Wed Apr 14, 2004 6:39 pm
by markl999
$query = "SELECT * FROM tms WHERE guia_madre='{$_GET['guia_madre']}'";

Posted: Thu Apr 15, 2004 1:07 pm
by ol4pr0
i wish i could tell you that that worked however i didnt.. i got back a blank page

let me post the relevant code again.

Code: Select all

<?
// 1st page 

$result = mssql_query("exec sp_wquery_manhdr01 " . $idc);
//$result = mssql_query("SELECT * FROM tms_manhdr01 ORDER by courier_id");

while($row = mssql_fetch_assoc($result)) {
                                                                                                                             
    echo " \n";
?>
<!-- $row guia madre -->
<td align="center" width="20%" BGCOLOR="#FFDECE" height="12"><b><font color="black" size="1" face="Verdana, Arial, Helvetica,sans-serif">
<? echo "<a href="2.php?id=$guia_madre"><img src="../images/i_arrow-s.png" border="0">$guia_madre</a>";?></font></b></td>

Code: Select all

<?
//2nd page

// db connection and all that..

$query = "SELECT * FROM tms_mandet01 WHERE numero_documento_transporte_master='{$_GET['guia_madre']}'";


while($row = mssql_fetch_assoc($result)) {
                                                                                                                             
  echo " \n";
?>
<table cellpadding="2" width="100%" cellspacing="1" border="0">
<tr>
<td align="left" BGCOLOR="#EEEEEE" WIDTH="1%" height="12">&nbsp;</td>
                                                                                                                             
<!-- $row nombre_consignatario-->
<td align="center" width="10%" BGCOLOR="#FFDECE" height="12"><b><font color="black" size="1" face="Verdana, Arial, Helvetica, sans-serif">
<?echo $row['nombre_consignatario']; ?></font></b></td>

// and alot more....

Posted: Thu Apr 15, 2004 1:22 pm
by markl999
In this line:
<? echo "<a href=\"2.php?id=$guia_madre\"><img src=\"../images/i_arrow-s.png\" border=\"0\">$guia_madre</a>";?></font></b></td>

Where is $guia_madre coming from/being set? If it's supposed to be from the query above it then shouldn't it be $row['guia_madre'] ?

Posted: Thu Apr 15, 2004 1:52 pm
by ol4pr0
yep it should be like that

its still like that because i was just editng it..

Code: Select all

it was

while(list($guia_madre.... = mssql_fetch_row($result))
now its

Code: Select all

<a href="2.php?id=<?echo $row['guia_madre'];?>"><img src="../images/i_arrow-s.png" border="0"><?echo $row['guia_madre'];?></a></font></b></td>

Kinda stuck here ...

Posted: Fri Apr 16, 2004 9:41 am
by ol4pr0
this is what my url looks like on the page where the variable is being passed.
http://myhost/2.php?id=014400146425

This is not coming from a form. it is only being passed using the URL

Code: Select all

<?
// if i would put in the following i do get a result.. so its not that something is wrong in the 
// query, the $guia_madre just doesnt receive the variable passed on URL

// LIke this gives a return but,, i just cant do it like this ($guia_madre = '014400146425'; )
/*
This didnt work 

$query = "SELECT * FROM tms_mandet01 WHERE numero_documento_transporte_master='{$_GET['guia_madreguia_madre']}'";
*/


// This doesnt work either... 

$guia_madre = $_GET['guia_madre'];

$query = "SELECT * FROM tms_mandet01 WHERE numero_documento_transporte_master='$guia_madre'";
$result = mssql_query($query)
 or die ("didnt do it");
                                                                                                                             
                                                                                                                            
while($row = mssql_fetch_assoc($result)) {
                                                                                                                             
  echo " \n";
?>
<table cellpadding="2" width="100%" cellspacing="1" border="0">
<tr>
<td align="left" BGCOLOR="#EEEEEE" WIDTH="1%" height="12">&nbsp;</td>
                                                                                                                             
                                                                                                                             
<?
if($row['direccion_consignatario'] !=NULL){
        // $row nombre_consignatario
echo "
<td align="center" width="10%" BGCOLOR="#FFDECE" height="12"><b><font color="black" size="1" face="Verdana, Arial, Helvetica, sans-serif">";
echo $row['nombre_consignatario'];
}
echo "</font></b></td>";

Posted: Fri Apr 16, 2004 10:06 am
by ol4pr0
Fix it...

Code: Select all

// this should have been 
echo "<a href="2.php?id=$guia_madre">

// !!!this 
echo "<a href=2.php?guia_madre=$guia_madre "
Thanks for the help ;-)