Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,665 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,158 people online right now. Registration is fast and FREE... Join Now!




Getting values from url

 
Reply to this topicStart new topic

Getting values from url

antiturncoat
post 13 Aug, 2007 - 02:02 AM
Post #1


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


I have a link that would pass a value to another page heres the code

CODE

<?php
        
           ob_start();
           include 'includes/connect.php';
           require_once('includes/connect.php');

           $query="Select * from products where status<>0";
           $result=mysql_query($query);
            
          $row1=mysql_num_rows($result);
          echo "<table align=\"center\" border=\"2\" cellspacing=\"1\">";
                echo "$br";
                echo "<tr>";
                echo "<td align=\"center\"><strong>Picture</strong></td>";
                echo "<td align=\"center\"><strong>Software Name</strong></td>";
                echo "<td align=\"center\"><strong>Category</strong></td>";
                echo "<td align=\"center\"><strong>Description</strong></td>";
                echo "<td align=\"center\"><strong>Price</strong></td>";
                echo "<td align=\"center\"><strong>Quantity</strong></td>";  
                echo "<td align=\"center\"><strong>Buy</strong></td>";
          echo "</tr>";
            while($array=mysql_fetch_array($result))
                               {
                                extract($array);
                                
                                echo "<tr>";

                                   echo "<td align=\"center\"><img src=".$picture."></td>";
                                   echo "<td align=\"center\"><font color=\"red\">".$sName."</font></td>";
                                   echo "<td align=\"center\">".$category."</td>";
                                   echo "<td align=\"center\">".$description."</td>";
                                   echo "<td align=\"center\">".$price."</td>";
                                   echo "<td align=\"center\">".$quantity."</td>";
                                   echo "<td align=\"center\"><a href= \"Admin.php?$sName\"><input name=\"Buy\" type=\"button\" value=\"Buy\"></a></td>";
                                
                                echo "</tr>";
                                }

             echo "</table>";
         ?>
    </div></td>


and im going to retrieve it in another page heres how i do it
CODE

          <input name="id" type="text" id="id" value ="<?php echo $_GET[sName] ?>">


but the textbox is empty... am i doing it right??
User is offlineProfile CardPM

Go to the top of the page

MitkOK
post 13 Aug, 2007 - 02:07 AM
Post #2


D.I.C Regular

Group Icon
Joined: 9 Aug, 2007
Posts: 314



Thanked 12 times

Dream Kudos: 250
My Contributions


CODE
echo "<td align=\"center\"><a href= \"Admin.php?sName=".$sName."\"><input name=\"Buy\" type=\"button\" value=\"Buy\"></a></td>";
User is offlineProfile CardPM

Go to the top of the page

no2pencil
post 13 Aug, 2007 - 03:57 AM
Post #3


My fridge be runnin OH NOEZ!

Group Icon
Joined: 10 May, 2007
Posts: 6,354



Thanked 58 times

Dream Kudos: 2375

Expert In: Goofing Off

My Contributions


QUOTE(antiturncoat @ 13 Aug, 2007 - 03:02 AM) *

CODE

          <input name="id" type="text" id="id" value ="<?php echo $_GET[sName] ?>">



If you can at least see the value being passed in the url, then you are using get:method correctly, try this:
CODE

<?php
    if($_GET['sName']) $sName=$_GET['sName'];
    else echo "sName was not passed<br>";
?>
<input name="id" type="text" id="id" value ="<?php echo $sName ?>">


Best of luck.
User is offlineProfile CardPM

Go to the top of the page

antiturncoat
post 13 Aug, 2007 - 05:29 AM
Post #4


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


geh thanks it really helps a lot.... thanks a million
User is offlineProfile CardPM

Go to the top of the page

antiturncoat
post 13 Aug, 2007 - 05:37 AM
Post #5


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


how about i pass 2 variables??

This post has been edited by antiturncoat: 13 Aug, 2007 - 05:40 AM
User is offlineProfile CardPM

Go to the top of the page

MitkOK
post 13 Aug, 2007 - 08:47 AM
Post #6


D.I.C Regular

Group Icon
Joined: 9 Aug, 2007
Posts: 314



Thanked 12 times

Dream Kudos: 250
My Contributions


If you want to pass a price for example :
CODE
echo "<td align=\"center\"><a href= \"Admin.php?sName=".$sName."&price=".$price\"><input name=\"Buy\" type=\"button\" value=\"Buy\"></a></td>";


example.com?param1=value1&param2=value2&param3=value3

-> $_GET['param1'] == 'value1'
-> $_GET['param2'] == 'value2'
-> $_GET['param3'] == 'value3'
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 05:50AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month