Page 1 of 1

Hyperlink and $_GET help

Posted: Mon May 29, 2006 5:29 pm
by MrPotatoes
test site. the [second link] is the one of importance: http://test.mr-potatoes.com
you can DL the code from this link: http://test.mr-potatoes.com/app.rar

[cliff's notes]: basically i'm not passing the parameter thru the URL or even getting it thru the form and getting it into the hyperlink. i see that no matter what i do i can't seem to get it. i've made another page to get the information and put it in there but it doesn't seem to work. not to mention that i can't get the information anyways from that new file. so i'm a little at ends here as how to solve this little problem i have here. help would be greatly appreciated

i don't think it's nessessary to post all the code here but i'll post snippets. you can DL the full source if you can't help me from what i have

you'll notice that the first link works just fine. that's not the one. that one uses java script and i was hoping to not have to do that. the second link you see that you can get in fine but you'll also notice that when you try to do the add operation it doesn't do anything. that is because i was trying to send the URL data thru a hyperlink in a form. maybe it's not the best way but i figured it would be ok. you'll also notice that no matter what numbers/letters you but in there you'll still get zeros. i echoed then out at the bottom for referance. it's easier to understand me

the view file has this one line that is supposed to put stuff into the URL for you to get the information from.

Code: Select all

<a href="http://localhost/framework/index.php?name=base&command=sum&a=<?=$this->model->a?>&b=<?=$this->model->b?>"> add</a>
the switch statement handles the URL information like so and is supposed to do 'stuff' with it. from there it retuns the information

Code: Select all

$gets = $this->get_params();
		
if (isset ($gets['command']))
	$this->model->command = $gets['command'];
if (isset ($gets['a']))
	$this->model->a = $gets['a'];
if (isset ($gets['b']))
	$this->model->b = $gets['b'];
	
	if (!isset ($gets['command'])) 
	$this->model->command = "index";

// set default view
$this->setView("plugins/_base/views/index.tpl");

switch ($this->model->command)
{			
	case 'index':
	break;
	
	case 'sum':
	$this->model->calcSum();
	break;
}
now the view file is a form. it's supposed to be a link but i do not want to do this thru a button for a few reasons. one being a nav bar. not everything can be a form button or radio button you know? it's just silly. so i have to redo this so that it actually passes the information.

Posted: Mon May 29, 2006 7:15 pm
by RobertGonzalez
My first thought to building your link is to try this...

Code: Select all

<?php
<a href="http://localhost/framework/index.php?name=base&command=sum&a=<?php echo $this->model->a; ?>&b=<?php echo $this->model->b ?>"> add</a>
?>
Second, are you trying to pass data from a form using a link? That is doabe, but only with javascript. What is your opposition to using a good old fashioned button?

And last, you can clean up your code a pinch by doing something like this...

Code: Select all

<?php
$gets = $this->get_params();
$this->model->command = 'index';
if (isset ($gets['command']))
        $this->model->command = $gets['command'];

if (isset ($gets['a']))
        $this->model->a = $gets['a'];

if (isset ($gets['b']))
        $this->model->b = $gets['b'];
       
// set default view
$this->setView("plugins/_base/views/index.tpl");

switch ($this->model->command)
{                     
        case 'index':
        break;
       
        case 'sum':
        $this->model->calcSum();
        break;
} 
?>
It'd be nice to be able to help you without having to download and unpack your code. You might want to consider posting it to make it easier to get help. Most folks, including myself, are a bit reluctant to go through that much to help someone.

Posted: Mon May 29, 2006 8:29 pm
by MrPotatoes
no. i'm an idiot. i figured it out

when you are as hardheaded as me and when you get frustrated you are not willing to do it correctly lmao!