SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
Thread: Reload a page after choice
-
Jun 21, 2007, 06:59 #1
- Join Date
- Nov 2004
- Location
- sweden
- Posts
- 646
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Reload a page after choice
Oops, now I'm tired and just can't make this thing work.
I have a page showing a specific listing for a chosen week.
So I made a form where I can pick a week number from a list.
Then I want my page to reload setting that week. Maybe would be good to make a Session of that as well, so I can remember it.
This is what I got now, that isn't working of course. But I've been doing stuff for hours now and just gt tired when I got to this.
PHP Code:<form name="form1" id="form1" method="post" action="index3.php?week=<?php echo $row_rs_week['week']?>">
<select name="week" id="week">
<?php
do {
?>
<option value="<?php echo $row_rs_week['week']?>"<?php if (!(strcmp($row_rs_week['week'], date("W")))) {echo "SELECTED";} ?>><?php echo $row_rs_week['week']?></option>
<?php
} while ($row_rs_week = mysql_fetch_assoc($rs_week));
$rows = mysql_num_rows($rs_week);
if($rows > 0) {
mysql_data_seek($rs_week, 0);
$row_rs_week = mysql_fetch_assoc($rs_week);
}
?>
</select>
<input type="submit" name="Submit" value="SHOW" />
</form>
-
Jun 21, 2007, 07:19 #2
- Join Date
- Aug 2004
- Location
- Manchester UK
- Posts
- 13,807
- Mentioned
- 158 Post(s)
- Tagged
- 3 Thread(s)
PHP Code:<form name="form1" id="form1" method="post" action="index3.php">
<select name="week" id="week">
<?php
do {
?>
<option value="<?php echo $row_rs_week['week']?>"<?php if (!(strcmp($row_rs_week['week'], date("W")))) {echo "SELECTED";} ?>><?php echo $row_rs_week['week']?></option>
<?php
} while ($row_rs_week = mysql_fetch_assoc($rs_week));
$rows = mysql_num_rows($rs_week);
if($rows > 0) {
mysql_data_seek($rs_week, 0);
$row_rs_week = mysql_fetch_assoc($rs_week);
}
?>
</select>
<input type="submit" name="Submit" value="SHOW" />
</form>Mike Swiffin - Community Team Advisor
Only a woman can read between the lines of a one word answer.....
-
Jun 21, 2007, 07:23 #3
- Join Date
- Nov 2004
- Location
- sweden
- Posts
- 646
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
I didn't get that? How do I do that?
Since I first get a menu with the current week selected.
But if the user picks another week I wnt to update the week in my list and also set a session to that selection when the page is reloaded.
-
Jun 21, 2007, 08:07 #4
- Join Date
- Aug 2004
- Location
- Manchester UK
- Posts
- 13,807
- Mentioned
- 158 Post(s)
- Tagged
- 3 Thread(s)
query the database with the $_POST['week'] variable from the form.
What does your query look like now?Mike Swiffin - Community Team Advisor
Only a woman can read between the lines of a one word answer.....
-
Jun 25, 2007, 00:10 #5
- Join Date
- Nov 2004
- Location
- sweden
- Posts
- 646
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
Now this is what I got from Dreamweaver
PHP Code:mysql_select_db($db_site_connect, $site_connect);
$query_rs_week = "SELECT * FROM tbl_week ORDER BY week ASC";
$rs_week = mysql_query($query_rs_week, $site_connect) or die(mysql_error());
$row_rs_week = mysql_fetch_assoc($rs_week);
$totalRows_rs_week = mysql_num_rows($rs_week);
-
Jun 25, 2007, 07:33 #6
- Join Date
- Nov 2004
- Location
- sweden
- Posts
- 646
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
What I actually needs is a form where the user can pick a week number. The current week should be initially selected. Thenwhen the user select a week number it would be great if that selection could be added as a session as well. Then reload the page with the new week selected.
Does anyone have an idea or solution?
-
Jun 25, 2007, 10:38 #7HTML Code:
<form name="form1" id="form1" method="post" action="samepage.php"> <select name="week" id="week"> <?php if ($_POST['week']) $_SESSION['week_chosen'] = $_POST['week']; elseif (!isset($_SESSION['week_chosen'])) $_SESSION['week_chosen'] = date('W'); $rs = mysql_query("SELECT * FROM tbl_week_list"); while ($row = mysql_fetch_assoc($rs)) { $sel = ($_SESSION['week_chosen'] == $row['week_num']) ? "selected='selected'" : ''; echo "<option value='$row[week_num]' $sel>$row[week_num]</option>"; } ?> </select> <input type="submit" name="Submit" value="SHOW" /> </form>
-
Jun 25, 2007, 11:26 #8
Bookmarks