variable help please

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pizmal
Forum Newbie
Posts: 19
Joined: Wed Jul 14, 2004 7:43 pm
Location: USA

variable help please

Post by Pizmal »

This is going to be hard to describe since i am new to PHP. I have a search page that gets data from a MYSQL database and displays it into a table (easy). Now when i show the ID number (workorder_ID) I turn it into a link to a formview page.

Code: Select all

while ($row= mysql_fetch_assoc($result)) {
  			print "<tr>";
			print "<td><a href="formview.php">".stripslashes($row['workorder_id'])."</a></td>";

$date = stripslashes($row['workorder_date']);
			print "<td>".date("m/d/y", $date)."</td>";

My problem is i want to carry the workorder_id number onto the next page. Went through search on this forum and it talks about sessions and security and that seems more complex than what i need. I dont care if someone alters the number. It would only allow them to change the page being view.

If you could possibly point me in the right direction that would be greatful. I thought I could use a $_request['id'] to save the variable but was unable to make it work

-- Pizmal


feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Why not encode it in the URL?

Code: Select all

print "<td><a href="formview.php?id=">".stripslashes($row['workorder_id'])."</a></td>";
That should do it...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

wouldn't he need to actually put the variable in the url ;) :P
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

$row['workorder_id]...that is the variable put into the url. :)
Pizmal
Forum Newbie
Posts: 19
Joined: Wed Jul 14, 2004 7:43 pm
Location: USA

Thank you

Post by Pizmal »

That worked. I was having problems with my code. I didnt remove the ' ' from the variable. Once i removed them it worked like a charm. Thanks for all your help.

What should i read up on to get more information on this?

-- Pizmal

PS: I will post the entire code next time so that you can see the PHP tags etc. Sorry i didnt do it this time. (first post)
Post Reply