Jump to content

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/131816-passing-data-in-a-url/
Share on other sites

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’”);

 

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 />";

 

}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.