paradoxmime Posted January 6, 2010 Share Posted January 6, 2010 I have a list of 'products' on a page and each row has a button I can select to put the product available or unavailable from searches. The problem, more like an issue is that it refreshes the page. This is a pain when I'm working at the bottom of the list. I have to scroll back down everytime I make a change. Anyway to keep everything right where it was? Link to comment https://forums.phpfreaks.com/topic/187464-need-help-with-_serverphp_self/ Share on other sites More sharing options...
PHP Monkeh Posted January 6, 2010 Share Posted January 6, 2010 Simple Method You could use link anchors to jump down to where you were after submitting. Complex Method You could use a mix of JavaScript to update the value without refreshing the page. The Way I Would Do It I'd make it a check box and then put an "Update" button at the very bottom of the page, when you submit the form it loops through all the checkboxes and changes their values accordingly Link to comment https://forums.phpfreaks.com/topic/187464-need-help-with-_serverphp_self/#findComment-989882 Share on other sites More sharing options...
paradoxmime Posted January 6, 2010 Author Share Posted January 6, 2010 So how would I do that with this: if($plan_active == 1) { echo " <a href=".$_SERVER['PHP_SELF']."?active_id=$Plan_ID&active_value=0&page=".$_GET['page']."&orderid=".$_GET['orderid']."&asc=".$_GET['asc']."><img src=\"gif/green.gif\" border=0></a>"; } else { echo " <a href=".$_SERVER['PHP_SELF']."?active_id=$Plan_ID&active_value=1&page=".$_GET['page']."&orderid=".$_GET['orderid']."&asc=".$_GET['asc']."><img src=\"gif/red.gif\" border=0></a>"; } Link to comment https://forums.phpfreaks.com/topic/187464-need-help-with-_serverphp_self/#findComment-989887 Share on other sites More sharing options...
PHP Monkeh Posted January 6, 2010 Share Posted January 6, 2010 Do you have a unique identifier for that particular row? Such as a row ID. I can see $_GET in there but nothing that relates to the row you've just pulled from the database. Link to comment https://forums.phpfreaks.com/topic/187464-need-help-with-_serverphp_self/#findComment-989903 Share on other sites More sharing options...
paradoxmime Posted January 6, 2010 Author Share Posted January 6, 2010 This precedes the code you have already looked at: $coloriter = 0; while($row = mysql_fetch_array($result)) { ## tri to set bgcolor of row $color = ($coloriter % 2) ? "#edefda" : "#CCCC99"; ## get last date modded if(trim($row['Date_Modded']) == "0000-00-00") { $modded = "Never"; } else { $modded = $row['Date_Modded']; } ####################################################### ## set $Plan_ID to current plan id in loop $Plan_ID = $row['Plan_ID']; # ## set Plan_Number to current plan_number in loop $Plan_Number = $row['Plan_Number']; # ## SET $plan_active to public field in db $plan_active = $row['Public']; ###################################################### $Plan_sales = $row['Sales_PDF']; $Plan_review = $row['Review_PDF']; ###################################################### $Plan_garage = $row['Garage_Location']; ###################################################### echo '<tr bgcolor="' , $color , '">'; ## added a </td> to close the field in the line below if ($row['Elevation'] <> "") { echo '<td bgcolor="FFFFFF" width="250"><img src="http://'.$_SERVER["HTTP_HOST"].'/Designers/'.$_SESSION["Des_ID"].'/jpg/' . str_replace('.jpg', '_small.jpg', $row['Elevation']) . '" /><br><div class="blue"><strong>TGC-'.$row['Plan_ID'].' '.$row['Garage_Location'].'</strong></div></td>'; } else { // no imageecho echo '<td align="center" bgcolor="FFFFFF" width="250">Image not provided</td>'; } ## added new column for activated plans echo '<td align="center">'; Link to comment https://forums.phpfreaks.com/topic/187464-need-help-with-_serverphp_self/#findComment-989938 Share on other sites More sharing options...
PHP Monkeh Posted January 6, 2010 Share Posted January 6, 2010 Alright so $Plan_ID is the unique identifier, perfect Lets make some changes then. This can all be done within your <a> tag so this is what the line should look like (varying depending on your if/else statement): echo " <a href=".$_SERVER['PHP_SELF']."?active_id=$Plan_ID&active_value=0&page=".$_GET['page']."&orderid=".$_GET['orderid']."&asc=".$_GET['asc']."#$Plan_ID name=$Plan_ID><img src=\"gif/green.gif\" border=0></a>"; Give that a shot The name=$Plan_ID so every link is unique, so that when you use #$Plan_ID on the end of the URL it will jump down to that link. Hopefully that'll solve your issues. Link to comment https://forums.phpfreaks.com/topic/187464-need-help-with-_serverphp_self/#findComment-989941 Share on other sites More sharing options...
paradoxmime Posted January 6, 2010 Author Share Posted January 6, 2010 This works much better. Thanks! Link to comment https://forums.phpfreaks.com/topic/187464-need-help-with-_serverphp_self/#findComment-989974 Share on other sites More sharing options...
paradoxmime Posted January 6, 2010 Author Share Posted January 6, 2010 Could I get some help with the other problem I have? http://www.phpfreaks.com/forums/index.php/topic,283062.0.html Link to comment https://forums.phpfreaks.com/topic/187464-need-help-with-_serverphp_self/#findComment-989976 Share on other sites More sharing options...
paradoxmime Posted January 8, 2010 Author Share Posted January 8, 2010 Ok, I realize that creating a bookmark does help a little but it doesn't quite do the trick. The reason for this is because if you are halfway down the page and click on the submit button, the page refreshes and then the line I was working on is now at the top of the page! I have seen pages where changes were made and everything remained exactly where it was. Maybe there is an alternative to using $_SERVER['PHP_SELF'] ??? Link to comment https://forums.phpfreaks.com/topic/187464-need-help-with-_serverphp_self/#findComment-991353 Share on other sites More sharing options...
crabfinger Posted January 8, 2010 Share Posted January 8, 2010 Why don't you just use a checkbox beside each entry like PHP Monkeh. Call it "invert[$Plan_ID]" then when all of the stuff you want to either activate or deactivate is selected just click update at the bottom, that's what I would do. Link to comment https://forums.phpfreaks.com/topic/187464-need-help-with-_serverphp_self/#findComment-991358 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.