almightyegg Posted June 24, 2007 Share Posted June 24, 2007 I have message board post IDs like 34.148 or gdis.9834 the bit before the full stop is the forum ID and the bit after is the post ID. What I need to do is select the forum ID and the post ID separately (without the full stop) how would I do this? Link to comment https://forums.phpfreaks.com/topic/56966-selecting-certain-parts-of-an-id/ Share on other sites More sharing options...
trq Posted June 24, 2007 Share Posted June 24, 2007 <?php $s = "gdis.9834"; $arr = explode('.',$s); echo "forum id = " . $arr[0]; echo "post id = " . $arr[1]; ?> Link to comment https://forums.phpfreaks.com/topic/56966-selecting-certain-parts-of-an-id/#findComment-281398 Share on other sites More sharing options...
almightyegg Posted June 24, 2007 Author Share Posted June 24, 2007 <form action="viewthread.php?f=<? echo "$fid"; ?>&t=<? echo "$tid"; ?>" method="GET"> <b>Input a Thread ID and jump straight to it:</b><br> Thread ID <input type="text" name="t"> <input type="submit" value="Jump to Thread"> <? $pos = $_GET['t']; $arr = explode('.',$pos); $fid = $arr[0]; $tid = $arr[1]; ?> </form> It doesn't seem to work in this.... Link to comment https://forums.phpfreaks.com/topic/56966-selecting-certain-parts-of-an-id/#findComment-281406 Share on other sites More sharing options...
trq Posted June 24, 2007 Share Posted June 24, 2007 It doesn't seem to work in this.... What exactly do you expect that code to do? Link to comment https://forums.phpfreaks.com/topic/56966-selecting-certain-parts-of-an-id/#findComment-281407 Share on other sites More sharing options...
almightyegg Posted June 24, 2007 Author Share Posted June 24, 2007 To jump straight to the thread that the user requests. It gets the forum, and the thread then it should put them into a link like so viewthread.php?f=forumID&t=threadID but instead it does viewthread.php?t=threadID.forumID Link to comment https://forums.phpfreaks.com/topic/56966-selecting-certain-parts-of-an-id/#findComment-281408 Share on other sites More sharing options...
AndyB Posted June 24, 2007 Share Posted June 24, 2007 Then your code is incomplete and structured wrongly, isn't it. Link to comment https://forums.phpfreaks.com/topic/56966-selecting-certain-parts-of-an-id/#findComment-281409 Share on other sites More sharing options...
almightyegg Posted June 24, 2007 Author Share Posted June 24, 2007 But I don't understand what's wrong with it <form action="viewthread.php?<? echo "f=$fid&t=$tid"; ?>" method="GET"> That's the line that makes the link and it is there....the only thing I can think of is it is remembering what used to be there. It used to be: <form action="viewthread.php?<? echo "&t=$pos"; ?>" method="GET"> but then I changed the setup of all my IDs in the tables today Link to comment https://forums.phpfreaks.com/topic/56966-selecting-certain-parts-of-an-id/#findComment-281410 Share on other sites More sharing options...
chigley Posted June 24, 2007 Share Posted June 24, 2007 Look at it, you define the variables after you try to echo them... Link to comment https://forums.phpfreaks.com/topic/56966-selecting-certain-parts-of-an-id/#findComment-281412 Share on other sites More sharing options...
almightyegg Posted June 24, 2007 Author Share Posted June 24, 2007 I always defined $pos after echoing them and it worked, because it needs to complete the form before looking at the link Link to comment https://forums.phpfreaks.com/topic/56966-selecting-certain-parts-of-an-id/#findComment-281413 Share on other sites More sharing options...
almightyegg Posted June 24, 2007 Author Share Posted June 24, 2007 Does anybody know how to do this?? Not necessarily using my script but basically I need an imput box where you enter ForumID.ThreadID and it turns it into a link like viewthread.php?f=ForumID&t=ThreadID Link to comment https://forums.phpfreaks.com/topic/56966-selecting-certain-parts-of-an-id/#findComment-281482 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.