Change PHP query from URL string to CODE

I have a script which pulls up details of a profile from XML code, depending on the PIN number in the URL (e.g. myurl.com/profile.php?pin=1922 will display information in echo statements for profile 1922).

It’s this code:

[php]<?php
if (!empty($_GET[‘pin’]))
{
$feedURL = ‘http://www.inveroak.co.uk/readerimages/livepanel/91255.xml’;
$showOpsWithNoPics = false;

try
{
$xml = simplexml_load_file($feedURL . ‘?’ . time());
$readers = $xml->xpath(’/ReaderDetails/Reader[Pin="’ . $_GET[‘pin’] . ‘"]’);
[/php]
How do I change it so I can set the PIN number I want it to search the XML and display information for IN THE CODE and NOT the URL?

For example:

[php]$readers = $xml->xpath(’/ReaderDetails/Reader[Pin="’ . $_GET[‘pin’] . ‘"]’);
[/php]To:

[php]$readers = $xml->xpath(’/ReaderDetails/Reader[Pin="’ . $_GET[‘pin == 4007’] . ‘"]’);
[/php]If I wanted PIN 4007?

Does anyone know?

Full Code:

[php]<?php
if (!empty($_GET[‘pin’]))
{
$feedURL = ‘http://www.inveroak.co.uk/readerimages/livepanel/91255.xml’;
$showOpsWithNoPics = false;

try
{
$xml = simplexml_load_file($feedURL . ‘?’ . time());
$readers = $xml->xpath(’/ReaderDetails/Reader[Pin="’ . $_GET[‘pin’] . ‘"]’);

foreach ($readers as $reader)
{
if ($reader->Picture == ‘None’ && $showOpsWithNoPics == false)
{
$picture = ‘’;
}
elseif ($reader->Picture == ‘None’ && $showOpsWithNoPics == true)
{
$picture = ‘images/defaultpic.jpg’;
}
else
{
$picture = $reader->Picture;
}

if ($picture != '')
{
    $name = $reader->Name;
    $pin = $reader->Pin;
    $status = $reader->Status;
    $description = $reader->Description;

    $arr_skills = '';
    $arr_subjects = '';
    foreach ($reader->Categories->Category as $Category)
    {
        foreach ($Category->Skill as $Skill)
        {
            switch ($Category['name'])
            {
                case 'Skills':
                    $arr_skills .= "<li>$Skill</li>";
                    break;
                case 'Subjects':
                    $arr_subjects .= "<li>$Skill</li>";
                    break;
            }
        }
    }

    $arr_shift = '';
    $hourWidth = 20;
    $PreviousDate = ""; 
    foreach ($reader->Rota->Shift as $Shift)
    {
        $Date = $Shift['Date'];
        $Day = date("l", strtotime($Date));
        $Start = $Shift['Start'];
        $Stop = $Shift['Stop'];
        if($Stop == '23:59:59' || $Stop == '00:00:00' ){$Stop = '24:00:00';}

        $Left = date("H",strtotime($Date.' '.$Start)) * $hourWidth;
        $Width = (round(abs(strtotime($Date.' '.$Stop) - strtotime($Date.' '.$Start)) / 60,2)/60)*$hourWidth;



        $compare = strcmp ($PreviousDate, $Date);


        if ($compare != 0)
        {
            if ($PreviousDate != '')
            {
                //this is not the first loop so close off the previous dayrow and hours divs
                $arr_shift.= '</div></div>';
            }
            //create a new day row
            $arr_shift .= '<div class="dayrow">';
            $arr_shift .= '<div class="day">'.$Day.'</div>';
            $arr_shift .= '<div class="hours">';
        }
        //add the shift object
        $arr_shift .= '<div class="shift" title="'. substr($Start,0,5).'-'.substr($Stop,0,5) .'" style="left:'.$Left.'px; width:'.$Width.'px; opacity: 1;"></div>';
        //set previouse date to the current shift's date so that we can check if we need to create a new day row next loop
        $PreviousDate = $Date;
    }
    //now we have finshed looping the shifts, either close the last div or display a message to show
    //we have no schedule for the op
    if ($Date != "")

{
$arr_shift.= ‘’;
}
else
{
$arr_shift.= ‘We are sorry but they have not scheduled their hours this week. Email for further details.’;
}
}
}
}
catch (Exception $e)
{
echo ‘cannot display operator profile’;
}
}

?>
[/php]I don’t want to use a variable string in the URL. It must be in the code and set to something I choose (I.E. LOOK IN THE XML FOR THIS PIN NUMBER AND RETURN IT, NOT LOOK IN XML FOR THE PIN NUMBER IN THE URL AND RETURN IT).

[php]$readers = $xml->xpath(’/ReaderDetails/Reader[Pin=“4007”]’); [/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service