...

View Full Version : I need some help passing info from one page to another when clicking a link



Selbyggen
08-18-2012, 06:17 PM
Hi there!
I'm pretty new to the PHP/mySQL world, however I've managed to setup tables, fill them with info from mySQL and so on, however now I've stumbled into a problem I haven't had before and I can't seem to find a good solution for it.


while($row = mysql_fetch_array($result))
{
$color = '#00FF00';
//find color by checking date
$date1 = new DateTime($row['forrige']);
$date2 = new DateTime(date('Y-m-d'));
$interval = $date1 -> diff($date2);
$years = $interval->format('%Y');
$months = $interval->format('%M');
if($years>0)$color = '#FF0000';
else if($months>8)$color = '#FF8000';
echo "<tr bgcolor='$color'>";
$kunde = $row['kunde'];
echo "<td>&nbsp;" . "<a href=ccustomerdetails.php>$kunde</a>" . "&nbsp;</td>";
echo "<td>&nbsp;" . $row['verdensdel'] . "&nbsp;</td>";
echo "<td>&nbsp;" . $row['land'] . "&nbsp;</td>";
if($row['avtale']==1)
echo "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JA </td>";
else
echo "<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NEI </td>";
echo "<td>&nbsp;&nbsp;&nbsp;" . $date1->format('Y-m') . "&nbsp;</td>";
echo "</tr>";
}
echo "</table>";


This is the file I use to finish tables by including it.

I want to make a code so I can click on the link echo "<td>&nbsp;" . "<a href=ccustomerdetails.php>$kunde</a>" . "&nbsp;</td>";, it will jump to the new php page, and at the same time send the $kunde value trough.

Sry if my code is a bit messy, this is my first php project so far, making a simple way to avoid an old excel sheet to be used at work... :P

Thank you for any answears :)

sh4rd
08-18-2012, 07:07 PM
<a href=ccustomerdetails.php?details=$kunde>$kunde</a>


Have a look at $_GET[]

Selbyggen
08-18-2012, 08:00 PM
<a href=ccustomerdetails.php?details=$kunde>$kunde</a>


Have a look at $_GET[]

Thank you! Now I did at least get a bit further :-)

However alot of the names has spaces.
Whenever a space is there, only the info in front on the space gets posted in the link. example: If the name was Nokia Siemens Network, it will only give me the "Nokia" part of it.

As usual; progress gives a new problem :P

Any ideas on how to handle that issue? :-)

Since the $kunde info gets sent the instant I click it, I can't change anything in it, like replace spaces with * or something similiar?

Selbyggen
08-18-2012, 08:47 PM
Solved it :-)

Added $rkunde = str_replace(" ",'*',$kunde); then transforming it back to spaces again on the other page.

I didn't think it was possible to do this since the page lists alot of data. It amaze me that php was able to figure what values for $kunde I actually wanted to be sent to next page :-)

Selbyggen
08-19-2012, 01:42 PM
How do I mark this as resolved? :P

Will Bontrager
08-19-2012, 03:18 PM
Solved it :-)

Added $rkunde = str_replace(" ",'*',$kunde); then transforming it back to spaces again on the other page.

I didn't think it was possible to do this since the page lists alot of data. It amaze me that php was able to figure what values for $kunde I actually wanted to be sent to next page :-)


Consider using
$kunde = urlencode($kunde);instead of str_replace().

Will

Selbyggen
08-19-2012, 10:25 PM
Consider using
$kunde = urlencode($kunde);instead of str_replace().

Will

Ah, excellent :-) looks better that way, so will do



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum