harkly Posted November 7, 2008 Share Posted November 7, 2008 I am new to php and cannot figure out how to move data from one page to another, I would like to do it in a URL. I don’t know the correct verbiage so it makes it harder for me to find this particular info. I have a form, search.php, which passes the info to results.php which makes a list of all names in my database. I then want to click on the name(s) and have that pass the ‘artid’ to artist.php which will have detailed info on that particular name and some images which I want to be clickable, passing the ‘imgid’ to another page with detail info on the images. So far my search.php works and I can get a list on the results.php but I can’t click on the name and pass that info on. All of my pages work independently. In results.php I have: echo “<a href=artist.php$id=artid>$fullName</a>\n” I know a problem lies here (=artist.php$id=artid) but can’t figure it out. Do I need a form method on the search.php or am I completely off the mark here? In artist.php: $search=@_GET[“artid”]; $results = mysql_query(“SELECT * from image where artid like ‘AR3614’”); My query works when I put in an actual ID (AR3614) Could someone could point me in the right direction. Quote Link to comment https://forums.phpfreaks.com/topic/131816-passing-data-in-a-url/ Share on other sites More sharing options...
Maq Posted November 7, 2008 Share Posted November 7, 2008 No, you don't need to put this in a form unless $id comes from an input field. Change these lines and it should work. If not echo them out and see what they output. echo "".$fullName." " $search=$_GET['artid']; Quote Link to comment https://forums.phpfreaks.com/topic/131816-passing-data-in-a-url/#findComment-684773 Share on other sites More sharing options...
php-pendejo Posted November 7, 2008 Share Posted November 7, 2008 I know this is crazy and above a new php programmers understanding but... if you want to get with more code and and make life easier place this in your code $ArrayList = array("_SERVER", "_COOKIE", "_ENV", "_FILES", "_POST", "_GET", "_SESSION"); foreach($ArrayList as $gblArray) { $keys = array_keys($$gblArray); foreach($keys as $key){ @$$key = trim(${$gblArray}[$key]); } } make you links as so echo "<a href=artist.php?artid=".$id.">".$fullName."</a><br />" then you can do your mysql as so $results = mysql_query(“SELECT * from image where artid like ‘$artid’”); Quote Link to comment https://forums.phpfreaks.com/topic/131816-passing-data-in-a-url/#findComment-684870 Share on other sites More sharing options...
harkly Posted November 8, 2008 Author Share Posted November 8, 2008 I got the second pass to work but I cannot get the variable to pass to my URL. Here's my code, mysql_select_db("artdb"); $search=$_GET["search"]; $result = mysql_query("SELECT * FROM artist WHERE fullName LIKE '%$search%'"); while ($r=mysql_fetch_array($result)) { $fullName=$r["fullName"]; $dob=$r["dob"]; $dod=$r["dod"]; $nationality =$r["nationality"]; $choosen_medium=$r["artForm"]; $artid=$r["artid"]; echo "<a href=artist.php?artid=".$artid.">".$fullName."</a><br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/131816-passing-data-in-a-url/#findComment-685105 Share on other sites More sharing options...
harkly Posted November 8, 2008 Author Share Posted November 8, 2008 Got it to work this is what I used echo "<a href='artist.php?artid=$r[artid]'>".$fullName."</a><br />"; Quote Link to comment https://forums.phpfreaks.com/topic/131816-passing-data-in-a-url/#findComment-685109 Share on other sites More sharing options...
Maq Posted November 10, 2008 Share Posted November 10, 2008 Next time you post could you use code or php tags? It's hard to read Also please mark this as solved. Quote Link to comment https://forums.phpfreaks.com/topic/131816-passing-data-in-a-url/#findComment-686811 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.