View previous topic :: View next topic |
Author |
Message |
mrtdunn -
Joined: 27 Jan 2005 Posts: 16 Location: Joplin,MO
|
Posted: Thu Jan 19, 2006 4:27 am Post subject: A lot of help please |
|
|
Ok guys. What I'd like to do is have a certain set of variables, say city names for example, in a drop menu. I would like to be able to select a city name and click a go button which will then display information regarding said city. I'd like to stay away from incorporating databases and just use a php file to call the information from. The drop down menu is a cinch for me. However making php do what I'd like it to do is not so. I'm not much of a programmer, but when I figure out what does what I can edit like nobodys business. Any and all help will be greatly appreciated. Thanks. |
|
Back to top |
|
 |
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
|
Back to top |
|
 |
comwiz3000 -
Joined: 19 Nov 2005 Posts: 51 Location: Wellington, NZ
|
|
Back to top |
|
 |
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Thu Jan 19, 2006 11:29 am Post subject: |
|
|
Depends I think but I'm no pro at php. :-D |
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jan 19, 2006 11:50 am Post subject: |
|
|
JavaScript is client side not server side. It has nothing to do with PHP, however you can echo JavaScript with PHP so it gets to the browser. _________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
 |
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Thu Jan 19, 2006 12:03 pm Post subject: |
|
|
I thought it was something like that ;-P |
|
Back to top |
|
 |
mrtdunn -
Joined: 27 Jan 2005 Posts: 16 Location: Joplin,MO
|
Posted: Thu Jan 19, 2006 4:24 pm Post subject: |
|
|
Thanks for the input thus far all. Sadly, I've stumped. With the amount of information I have, it seems like I'm going to have to use a db. Here is an example of what I'm trying to do. http://www.limousine-chicago-illinois.com Note the Check our Rates form and the information it displays on submit. My lack of programming knowledge is driving me bonkers here. I'm going to go back to sitting in the corner rocking and tapping myself in the forehead for a while. Thanks again. |
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jan 19, 2006 5:11 pm Post subject: |
|
|
All you need is a simple php script to do it. I see what you want now. You need it so you click the submit button and it checks the value of the drop down list. The php file searches through an array or a load of ifs (array will be better) and redirects the frame to the page with those rates on, correct?
If so you could use javascript for it, but PHP might be easier. _________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
 |
mrtdunn -
Joined: 27 Jan 2005 Posts: 16 Location: Joplin,MO
|
Posted: Thu Jan 19, 2006 8:15 pm Post subject: |
|
|
That is exactly what I want it to do. But I have idea on how to make a script that will do that. If anyone knows where I might find a script that will do this please........show me the way. Thanks. |
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jan 19, 2006 8:40 pm Post subject: |
|
|
I could help you with the If's one but its a lot of work, where as some one could design on using arrays so it goes to the page that you used the value of, for example, when you click UK, the value is united_kindom so the php script will make it go to united_kindom.html.
Mine will be long winded. Someone with more php knowledge will be better. _________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jan 19, 2006 9:34 pm Post subject: |
|
|
OK, I came up with a very small solution.
The code probably wont work because I havent tested it. But here goes. You'll have to fault find or see if someone corrects it. :-)
Code: | <?php
$gotopage = $_POST['menu']; //menu is the name of the field in your form
header("Location: $gotopage");
?> |
Make each value in your form the name of the page you want it to go to, eg. uk.html, usa.html.
Set it up to post to that php file and it should work no problems, except for fault finding to start with if it doesnt.
Hope this helps. _________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Thu Jan 19, 2006 9:49 pm Post subject: |
|
|
I just read the first post so whatever.
Code: | <html>...
<?php
$cities = array("cardiff" => "Capitol city of Wales.", "london" => "Capitol city of England.");
// Upper case on the key name will CENSORED it up, if you want to upper case specific words only, you'll have to create a second array and loop through the keys and lower case them for selection.
if ($_GET['do_view'] && $_GET['city'] !== "" && array_key_exists($_GET['city'], $cities))
echo $cities[$_GET['city']];
else {
?>
<form action='<?=$_SERVER['PHP_SELF']?>' method=get>
<select name='city'>
<?php
foreach(array_flip($cities) as $city)
echo "<option value='".$city."'>".ucwords($city)."</option>\n";
?>
</select>
<br>
<input type='submit' name='do_view' value='View City'>
</form>
<? } ?>
...</html> |
The Inquisitor -> You could just one-line that. _________________
 |
|
Back to top |
 |
 |
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jan 19, 2006 9:54 pm Post subject: |
|
|
Try and do that with yours ;-) _________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Thu Jan 19, 2006 10:06 pm Post subject: |
|
|
Code: |
<?php $cities = array("cardiff" => "Capitol city of Wales.", "london" => "Capitol city of England.");
if ($_GET['do_view'] && $_GET['city'] !== "" && array_key_exists($_GET['city'], $cities)) echo $cities[$_GET['city']]; else foreach(array_flip($cities) as $city) echo "<a href='?do_view=1&city=".$city."'>".ucwords($city)."</a>, "; ?>
|
The array doesn't count. _________________
 |
|
Back to top |
 |
 |
mrtdunn -
Joined: 27 Jan 2005 Posts: 16 Location: Joplin,MO
|
Posted: Fri Jan 20, 2006 1:21 am Post subject: |
|
|
Wow. Now to stop my head from spinning and sort through this and see what I can come up with. Thanx very much for all the suggestions. |
|
Back to top |
|
 |
|