Forum Moderators: coopster
Appreciate your help and time.
<form action="somescript"> = GET
<a href="somescript"> = GET
In PHP you can access either, if you don't know what they will be, via $_REQUEST.
Google for get and post methods so you know them, as there are reasons to use both. Get has two peculiarities. One, there is a limitation in size that can be sent and received, and two, it will show up in the address bar as a query string.
somescript.php?var1=1&var2=2&var3=3
In my menu I write:
<form action="main.php" method="get"><a href="main.php?mini7=1">miniputt: 8 år</a></form>
In main.php I write:
if isset($_GET['mini7']){
$result = mysql_query(" SELECT * FROM `undersider` WHERE `super_avdeling` = 'SMÅGUTT: 7 ÅR' LIMIT 0 , 30 ");
while($myrow = mysql_fetch_array($result))
{
echo '<p><span class=overskrift>'.$myrow['overskrift'] . ' (' . $myrow['dato'] . ')';
echo '</span>';
echo '<p class=ingress>'. $myrow['ingress'];
echo '<p class=tekst><img src=' . $myrow['bilde'] . ' align=left vspace=10 hspace=5 width=300>' . $myrow['tekst'];
}
}else{
echo 'feil';
}
I'm trying to put together a web-page for our local soccerteam for kids.
In my menu I write:
<form action="main.php" method="get"><a href="main.php?mini7=1">miniputt: 8 år</a></form>
The form is not needed.
<a href="main.php?mini7=1">miniputt: 8 år</a>
if (isset($_GET['mini7']) and preg_match('/^\d+$/',$_GET['mini7'])){
// The preg_match insures it's nothing but a number.
// Other ways to do it ....
$result = mysql_query(" SELECT * FROM `undersider` WHERE `super_avdeling` = '$_GET['mini7']' LIMIT 0 , 30 ");
..........
}
if you're storing your data as plain text, this is going to be a never ending nightmare:
`super_avdeling` = 'SMÅGUTT: 7 ÅR'
This should be an integer field, like
table undersider
id....¦.........title........¦....super_avdeling....¦
1.....¦.miniputt: 8 år.¦...1..................¦
Previous for example only, but this is the idea. Searching on integer fields will always be faster and simplifies the task. It also simplifies security issues too, as in the simple preg_match above. That field will never accept anything but integer numbers as described. If it accepts textual input you have to take another more complex approach.