Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts

    I need some help passing info from one page to another when clicking a link

    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.
    PHP Code:
    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
    Last edited by Selbyggen; 08-18-2012 at 05:19 PM. Reason: From [code] to [php]

  • #2
    New Coder
    Join Date
    Aug 2012
    Posts
    11
    Thanks
    0
    Thanked 1 Time in 1 Post
    PHP Code:
    <a href=ccustomerdetails.php?details=$kunde>$kunde</a
    Have a look at $_GET[]

  • Users who have thanked sh4rd for this post:

    Selbyggen (08-18-2012)

  • #3
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by sh4rd View Post
    PHP Code:
    <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?

  • #4
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Solved it :-)

    Added [IPHP]$rkunde = str_replace(" ",'*',$kunde);[/IPHP] 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 :-)

  • #5
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts
    How do I mark this as resolved? :P

  • #6
    Regular Coder
    Join Date
    Jun 2012
    Location
    Near Chicago, USA
    Posts
    123
    Thanks
    7
    Thanked 19 Times in 19 Posts
    Quote Originally Posted by Selbyggen View Post
    Solved it :-)

    Added [IPHP]$rkunde = str_replace(" ",'*',$kunde);[/IPHP] 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
    Code:
    $kunde = urlencode($kunde);
    instead of str_replace().

    Will
    Last edited by Will Bontrager; 08-19-2012 at 02:18 PM. Reason: typo in code
    Numerology API for apps - Facebook, iPad, mobile phones. No charge to use API. [info]

  • Users who have thanked Will Bontrager for this post:

    Selbyggen (08-19-2012)

  • #7
    New Coder
    Join Date
    May 2011
    Posts
    10
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Will Bontrager View Post
    Consider using
    Code:
    $kunde = urlencode($kunde);
    instead of str_replace().

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •