PHP - How To Get Current Url
Hey all,
How can i get the current URL including any $_POST variables which arent visible? Thanks. Similar Tutorialsi get this error Warning: current() [function.current]: Passed variable is not an array or object.. for this Code: [Select] $lastblock = current( ${"s".$row} ); print_r($lastblock); when i change to this it works.. Code: [Select] $lastblock = current( $s0 ); print_r($lastblock); The problem is i won't know the $row seeing as it is in a while loop. Solution? Hi, I'm wanting to find rows whose date is within the next week of the current month of the current year. The format of the date is, for example: 2010-10-28 Any ideas guys? Thanks lots! Hello - I've come to an issue with something I'm working on and have searched around with no luck. When editing user accounts I want it to not be able to change the e-mail address into existing ones on other rows, but when submitting the form it takes into account that this particular rows email address is the same as the one which was sent via $_POST and throws up the error. The desired behaviour I want is for it to ignore the ID of the row which was posted, but take into account every other row. Here's the code as it stands at the moment: $email = $_POST['email']; $checkemail = mysql_query("SELECT email FROM users WHERE email='$email'"); } if (mysql_num_rows($checkemail) > 0) { return $this->error("The e-mail address you provided is already associated with an account."); } Hi i have this drop down list current the year is 2010 and downwards but i want to change the list to 2010 upwards u can notice on the 50-- so shows current year minus so current is 2010 to 61 how can i change 2010 to 2030 or sunfin?? echo '<select name="year_of_birth">',"\n"; $year = date("Y"); for ($i = $year;$i > $year-50;$i--) { if($i == $thisYear) { $s = ' selected'; } else { $s=''; } echo '<option value="' ,$i, '"',$s,'>' ,$i, '</option>',"\n"; } echo '</select>',"\n"; HI There, I am using this type of code to self load a submitted form <form name = "testform" method = "post" action = "<?=$_SERVER['PHP_SELF']?>" onsubmit = "return check_data()" > Apart from using $_SERVER['PHP_SELF'] is there another way of determining the current URL within a script ? regards, Steven Matthews $_SESSION[$c] is an array in a loop. How do i do an if statement that gets the current array key? Code: [Select] if($_SESSION[$c][]==$_SESSION[$c][1]) { } i tried the above but i get this error "Fatal error: Cannot use [] for reading in..." Hi, I have some code that I think worked at one point, but now it doesn't. I have a side navigation menu which I have set as an include. I want to change CSS styling to a current state to whatever page you are current on. For instance the portfolio link would look like this. Code: [Select] <li><a id="current" href="../Portfolio/" title="Visit my Portfolio">Portfolio</a></li> Both the page I am trying to set this on and my includes are in separate directories, so I am not sure if that is messing things up, but the id="current is not being set with what I currently have as my code. Here is my current code. <?php $menu = <<< MENU <div id="SideMenu"> <div id="button"> <img src="../images/NavButton.png" width="184" height="32" class="menu_class" /> <ul class="the_menu"> <li><a href="../index.php" title="take me home">Home</a></li> <li><a href="../Portfolio/" title="Visit my Portfolio">Portfolio</a></li> <li><a href="../blog/" title="See what I have to say">Blog</a></li> <li><a href="../Contact/" title="Get in Touch with me">Contact</a></li> </ul> </div><!--end button div--> </div><!--end SideMenu div--> MENU; $lines = split("\n", $menu); foreach ($lines as $line) { $current = false; preg_match('/href="([^"]+)"/', $line, $url); if (substr($_SERVER["REQUEST_URI"], 0, 5) == substr($url[1], 0, 5)) { $line = str_replace('<a h', '<a id="current" h', $line); } echo $line."\n"; } ?> any ideas? Hi;
I would like to get the current timestamp but the question is that i want to get the real time which is the machine bios time that can't change by the server administrator and not the server time which can be modified to any value.
Thanks
is this possibe with php? Hello! Once again, I find myself in the need of help regarding PHP. What I have is a URL that looks like this: http://domain.com/gallery/?album=3&gallery=65 What I need is to extract the number that comes after "album=". In this case, it would be the number 3. I currently have this: <?php $url=getPageURL(); $var=explode('album=',$url); $var=explode('?',$var[1]); ?> My problem is that it doesn't result in anything. Can anyone lend a hand? :) It would be much appreciated. Hi, I am trying to write an SQL to XML converter, so so far I have all the records inputted into the db tables, and now I want to append a child, but I don't know how to compare current row's field value with the next row below it, specifically I want to check if a current row is parent of the next row. I have already got the XML to SQL function working (some bugs but for the most part it's working) So for eg: <?php $query=mysql_query("SELECT * FROM edge"); while($row=mysql_fetch_assoc($query) ) { if($row['target'] is parent of the next row), then append the next row as child of current row } ?> Table edge is one of the tables that hold target node/source(aka: parent) nodes. Any help much appreciated! Why this code dont work :S <?php echo ' <ul> <li'; if ($_SERVER['PHP_SELF'] == "kategorije.php") { echo ' id="current"'; } echo '><a href="kategorije.php"><span>Kategorije</span></a></li> </ul>'; ?> Checking if PHP_SELF is "kategorije.php" do not work, why, and what is solution ? What I am trying to do is I am making a Event page and I would like to have it list the events in 2 sections. One being "On" or "Before" current date and the next being "Past" current date so I can list the events in "Upcoming Events" and "Past Events" the code im showing here is for the listing of my event page I just need help turning this query into two separate querys with the date function im looking for. Code: [Select] <?php $result = mysql_query("SELECT * FROM event ORDER by eventdate DESC"); if (!$result) { die("query failed: " . msql_error()); } while ($row = mysql_fetch_array($result)) { list($id, $eventdate, $header, $description, $image, $location) = $row; $description = nl2br($description); $eventdate = date("M j, Y",strtotime("$eventdate")); print(' <table width="680" border="0" cellpadding="14" cellspacing="0"> <tr> <td> <div class="myFont"><font size="+1" color="#4e8baf">'.$eventdate.' - </font><font size="+1"><b>'.$header.'</b></font></div> <font size="+1"><a href="event.php?list=true&eventid='.$id.'">Details</a></font><br /> <hr color="#FFFFFF" width="100" align="left" size="1"> </td> </tr> </table> '); } ?> I am trying to create a script that alters the navigation div depending on the page the user is on. How do I get the current page using PHP? Hi, I am trying to build a function that takes in the current primary key as a parameter. My question is how do I extract it/retrieve it and store it in a variable? Any help is much appreciated! Folks, " http://www.example.com/whatever/whatever.htm " how to Grab the Domain name from URLs? like "http://www.example.com" Any suh PHP Cde? I'm looking to enter the current time and date into a mysql database using php. My current code looks like this: Code: [Select] $now = date("m/d/y",time()); I then insert $now into the table into a datetime column. This all works but the time when read from the column appears as 0000-00-00 00:00:00. Any ideas what I'm doing wrong? Thanks in advance. I am building a site that needs to update member accounts on a weekly basis. At the moment I have a cron job set for 12:01 am on Monday, that resets five database fields for all of my members. The first field is the current week, the second field is the previous week, the third field is from two weeks ago, the fourth field is from three weeks ago, and the fifth field is from four weeks ago. Obviously the cron job resets the first field to 0, and the data from this field is moved to field two (last week), and so on and so forth, and the data from the fifth field is just removed altogether. However, this is really not preferred, because if/when I get 1000+ users, the cron job will take up a crapload of CPU as many mysql queries need to be executed for each account. So, I am trying to implement a script that checks the last login date for a user, and if they have have not logged in since before the latest Monday, the Monday before that, the Monday before that, or the Monday before that, etc. I have never really worked with dates, so I don't even know how to begin. The last user login is stored as a DATA datatype in a mysql database, and is in the following format: YYYY-MM-DD. Thanks in advance! Hi, when i try to insert to table date value it gives me wrong current date. $joindate = date('m-d-Y'); $sql = mysqli_query($con,"INSERT INTO staff (OracleID,StaffName,Des,joindate,username,password,isadmin) VALUES ('$oracleid','$name','$des','$joindate','$username', '$pass','$isadmin')"); i get this in the main page after making date("d-m-Y",strtotime(date)) 30-11--0001 why is that? Edited April 7, 2020 by ramiwahdanHi, This may be something for JavaScript but I would like to know if and how it's possible to show who is currently active/viewing the page. Users are logged into the system with their own account. The purpose of this is for a CRM where more than one person may be editing the same record, so undesired overwrites might occur which is what I'd like to avoid with this "other user editing this record" notification. |