Need help with some simple php problem...
Moderator: General Moderators
-
phppadawan
- Forum Newbie
- Posts: 5
- Joined: Thu Mar 31, 2011 4:55 pm
Need help with some simple php problem...
Hey everyone,
I am not a big php coder, i know my html and what not but i need help with something thats probably pretty simple to you guys. Heres what I need help with.
I have a text box and enter button I just need it to display different results for a certain input range.
For example lets say I want the person to enter results 1-100, but I only want to display 10 different results for each input 1-10 will send them to a different link, 11-20 to a different link, 21-30, etc.
Whats the best way to do this?
I am not a big php coder, i know my html and what not but i need help with something thats probably pretty simple to you guys. Heres what I need help with.
I have a text box and enter button I just need it to display different results for a certain input range.
For example lets say I want the person to enter results 1-100, but I only want to display 10 different results for each input 1-10 will send them to a different link, 11-20 to a different link, 21-30, etc.
Whats the best way to do this?
Re: Need help with some simple php problem...
set a limit mysql query as a variable..and create dynamic links with those variables..
-
phppadawan
- Forum Newbie
- Posts: 5
- Joined: Thu Mar 31, 2011 4:55 pm
Re: Need help with some simple php problem...
now thats getting into stuff i have zero experience in. Would you be willing to do this for me for some compensation?
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Need help with some simple php problem...
This is called pagination and as the other poster points out, it uses sql's LIMIT option.
This query will start from the record 0 and display 10 records (including the first one).
Code: Select all
<?php
$qry = mysql_query("SELECT * FROM table LIMIT 0, 10");
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
-
phppadawan
- Forum Newbie
- Posts: 5
- Joined: Thu Mar 31, 2011 4:55 pm
Re: Need help with some simple php problem...
Hmm, I think i might not have explained it enough. This stuff seems a little over kill for what I want. Let me see if i can explain it better.
All I need really in theory is a simple redirect to different part of my website once the users inputs his number. In this case his credit score number. I will be asking him what his credit score number will be and there will be a empty text box with an enter button. All i need it to do is if he puts in 450 for example, then it will send him to mywebsite.com/450-460.php, Meaning anyone who puts in a number 450-460 will get sent there.
and anyone who puts in a number 461-470 will get sent someplace else. It seems like an easy thing to do without getting into databases and all that with like a simple, if code.
Can it be done this way or is the only way to do it with a database?
All I need really in theory is a simple redirect to different part of my website once the users inputs his number. In this case his credit score number. I will be asking him what his credit score number will be and there will be a empty text box with an enter button. All i need it to do is if he puts in 450 for example, then it will send him to mywebsite.com/450-460.php, Meaning anyone who puts in a number 450-460 will get sent there.
and anyone who puts in a number 461-470 will get sent someplace else. It seems like an easy thing to do without getting into databases and all that with like a simple, if code.
Can it be done this way or is the only way to do it with a database?
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Need help with some simple php problem...
You actually explained it totally different the first time.phppadawan wrote:Hmm, I think i might not have explained it enough. This stuff seems a little over kill for what I want. Let me see if i can explain it better.
There could be a switch statement involved that tested the value of your input and based on that redirected the user to the specific page. This would not require a database.phppadawan wrote:It seems like an easy thing to do without getting into databases and all that with like a simple, if code.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
-
phppadawan
- Forum Newbie
- Posts: 5
- Joined: Thu Mar 31, 2011 4:55 pm
Re: Need help with some simple php problem...
awesome thats what I had thought. Could you write it up for me ill paypal you 5$?
Re: Need help with some simple php problem...
basically you're filtering your form validation..can you a switch statement or if else statements...which ever you prefer
-
phppadawan
- Forum Newbie
- Posts: 5
- Joined: Thu Mar 31, 2011 4:55 pm
Re: Need help with some simple php problem...
anyone willing to do this for 5$?
Re: Need help with some simple php problem...
you could just use if statements if you have all of the pages already made for each number group
Re: Need help with some simple php problem...
Here is your solution:
The form:
Redirection page "redirect.php":
Now all you have to do is add more elseif conditions.
Or you could do something like this:
The form:
Code: Select all
<html>
<form id="form1" name="form1" method="post" action="redirect.php">
<p>Enter your credit scroe
<input type="text" name="score" id="score" />
<input type="submit" name="submit" id="submit" value="Submit" />
</p>
</form>
</html>Code: Select all
<?php
$score = $_REQUEST['score'];
if($score => 450 && $score < 460){
header("Location: mywebsite.com/450-460.php");
}elseif($score => 460 && $score < 470){
header("Location: mywebsite.com/460-470.php");
}
?>Or you could do something like this:
Code: Select all
<?php
$score = $_REQUEST['score'];
for($i = 0; $i <= 900; $i += 10){
if($score => $i && $score < ($i+10)){
header("Location: mywebsite.com/".$i."-".($i+10).".php");
}
}
?>
Last edited by klandaika on Fri Apr 01, 2011 3:41 am, edited 1 time in total.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Need help with some simple php problem...
What is the maximum (& minimum) value a user can enter and what increments do you want? In the example you indicate 10, is that correct?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering