Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to pass id to another page where id ia a primary key auto increment
Old 06-02-2005, 02:33 AM How to pass id to another page where id ia a primary key auto increment
waller's Avatar
Skilled Talker

Posts: 59
Location: North Borneo.
Trades: 0
I have a table with a auto increment primary key named 'id'. My problem is, how can i pass 'id' from page to page.I need this do edit and delete data from the table.Thank you.
waller is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-02-2005, 03:16 AM
Marvin Le Rouge's Avatar
Skilled Talker

Posts: 52
Trades: 0
Why not use sessions ?
Marvin Le Rouge is offline
Reply With Quote
View Public Profile
 
Old 06-02-2005, 10:04 AM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
or also, you can pull out the id for the user (if ur doing a login script) and use a form to post it to other page... like profile page to update profile where the id is the users id
feraira is offline
Reply With Quote
View Public Profile
 
Old 06-02-2005, 09:00 PM
waller's Avatar
Skilled Talker

Posts: 59
Location: North Borneo.
Trades: 0
its not a login script. its like.....I want to click this one link 'name' with id '5' and it will automatically send me to this page editcontact.php?id=5 .I manage to do this but please tell me how to get the id. I mean, I need to use the sent id in editcontact.php .I tried $theID=$_POST["id"] but it did'nt work.
waller is offline
Reply With Quote
View Public Profile
 
Old 06-02-2005, 10:18 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
$_POST is for getting values from POST forms. Use $_GET for getting values from the query string
PHP Code:
$theID $_GET['id']; // editcontact.php?id=5, $theID = 5 
Look at the superglobals on the manual for more info.
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Old 06-05-2005, 09:21 PM
waller's Avatar
Skilled Talker

Posts: 59
Location: North Borneo.
Trades: 0
Thanks for the tip. Now, I have another problem.
When i use the '$_GET['id']' to get the id number I want, I was not just an interger. For example, if I get the id '12' from the url, and when I use echo to display it, its not just 12. It was "12". A twelve with a Double Quote.
I strip the doublequote with substr( $theID,1,1). This work just fine for id 1-9. For example $theID=9, substr( $theID,1,1) will return 9. But if $theID=12, substr( $theID,1,1) will return 1. $theID=32, substr( $theID,1,1) will return 3. Yes....it will only return the first number.
Is there any other function in php to only strip the doublequote?, or does anyone have any personally created function to strip the doublequote?
waller is offline
Reply With Quote
View Public Profile
 
Old 06-05-2005, 09:55 PM
Christopher's Avatar
Iced Cap

Latest Blog Post:
Cross-domain AJAX with JSONP
Posts: 3,110
Location: Toronto, Ontario
Trades: 0
You can just use str_replace to replace the double quotes with nothing:
PHP Code:
$id str_replace('"'''$id); 
Or perhaps getting rid of all non-numeric characters would do you better:
PHP Code:
$id preg_replace('#[^0-9]+#'''$id); 
__________________

Please login or register to view this content. Registration is FREE
- Latest Articles:
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE

--
Please login or register to view this content. Registration is FREE

Christopher is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to pass id to another page where id ia a primary key auto increment
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24688 seconds with 12 queries