PHP - .htaccess Write Php String Query In Url
Okay so i have a URL like this..
https://www.mysite.com/board/profile.php?user=1I want the URL to be like this.. https://www.mysite.com/user/1.htaccess rewrites have always confused me. Similar TutorialsConsider the following POS-tagged string: Code: [Select] It/PRP was/VBD not/RB okay/JJ or/CC funny/JJ and/CC I/NN will/MD never/RB buy/VB from/IN them/PRP ever/RB again/RB (It was not okay or funny and I will never buy from them ever again) I want to accomplish the following: Check for negating adverbs (RB) against defined array('not', 'never') When there's a match, remove the adverb Concatenate "not-" to the beginning of every subsequent adjective (JJ), adverb (RB), or verb (VB or VBN for past tense) Remove all POS-tags (/XX) Thus, the desired output would be: Code: [Select] It was not-okay or not-funny and I will not-buy from them not-ever not-again My first thought was to do this the way I know how to: explode the string on space, then explode every word on "/" to [JJ => okay], then make a switch statement to treat every word (case JJ: concatenate, etc.), but this seems very sloppy. Does anybody have a more clean and / or efficient way of doing this, for instance regex? The strings have been pre-cleaned, so they will always only contain words (no punctuation, other characters than a-z, etc.). Any tips, example code fragments, etc. would be greatly appreciated! *Edit: I am aware, btw, of the very basic character of this way of treating negations, but it is good enough for what I need. There will be an error margin, but that's ok * I am trying to create a query that selects results from a table called matches. The results from this table must be based on whether or not there are results from another table called match_results. The results from the match_results table must be based on whether or not the row has either a home_id equal to the current team id, or a visitor_id equal to the current team id. If the current team id is equal to the home_id of the result from the match_results table, then the home_score must be greater than the visitor_score. If the current team id is equal to the visitor_id of the result from the match_results table, then the visitor_score must be greater than the home_score. In short, I am trying to make a query that finds a team's match record(wins and losses). If the result from the matches table doesn't have any results from the match_results table with the same match id, then it hasn't been played it. I hope this makes sense. Is there any way to do this in one single query? [attachment deleted by admin] The Query:
$query = "SELECT * FROM ttn01 WHERE id = $_GET['id']";I am getting an error. I've made a few attempts at this, but I'm likely not making much sense.... I'm working on how to phrase the question. I had a MySQL database where I used to combine user first AND last names in a single string... I called that string "Member" So if I filtered: www.mysite.com/members.php?Member=Peter It would find and display all Peters: Peter Rabbit and Peter Griffith and Pope Peter. This is what I want. I'm now keeping each name (first and last) in separate strings (as separate variables?), and I am combining them in an array to display on the website: Code: [Select] $First = $First; $Last = $Last; $member = array($Last, $First,); foreach ($Member as $key => $v ) if (!$v) unset ($Member[$key]); $Member = implode(', ', $Member); echo $Member; Now I've lost the ability to search all the members for Peter. So if I filtered: www.mysite.com/members.php?First=Peter ...it would work.... for Peter Rabbit and Peter Griffith, but not Pope Peter I cannot query the entire array? I can no longer check members (first and last names) for Wayne? www.mysite.com/members.php?Member=Peter I'm betting I can, but there's a lot more to it... and 8 hours of Googling haven't helped much. Thanks for listening. ~Wayne I'm going to create a web page with <iframe> tag & want that the src of <iframe> change as Greetings, I'm looking for a way to pass a query string (from page1) as part of a query string (to page2) as a single key=>value pair. The idea is the use the query string to return the user to the previous page after the action has been completed. query results[page1]->view record/action selection[page2]->back to results[page1] I'm sure someone has been down this path before. P.S. the script is all contained within one file, thus the filename.ext is already known. Thanks Hi guys,
I am using this code to open and close a pop up window, but as soon as i click the close button this
http://localhost/popup.php?random=&button=
automatically adds in the url, Please tell me what is wrong with the script
<script type="text/javascript"> $(document).ready(function(){ $('a.popup-window').click(function(){ var popupBox = $(this).attr('href'); $(popupBox).fadeIn(400); var popMargTop = ($(popupBox).height() + 24)/2; var popMargLeft = ($(popupBox).width() + 24)/2; $(popupBox).css({ 'margin-top' : -popMargTop, 'margin-left' : -popMargLeft }); $('body').append('<div id="mask"></div>'); $('#mask').fadeIn(400); return false; }); $('button.close,#mask').live('click', function(){ $('#mask,.popupInfo').fadeOut(400,function(){ $('#mask').remove(); }); return false; }); }); $(document).keyup(function(e){ if(e.keyCode ==27){ $('#mask,.popupInfo, #popup-box').fadeOut(400); return false; } }); </script> </head> <body> <a href="#popup-box" class="popup-window">Click</a> <div id="popup-box" class="popupInfo"> <form> <label>ANYTHING</label></br> <input type="text" name="random"/></br> <button type="submit" name="button" class ="close">close</button> </form> </div> </body> </html> Edited by chauhanRohit, 27 June 2014 - 09:46 AM. Hi there, im trying to have a form show up when user clicks "add joke". I need the variable to be retrieved from the url query string. I cant get the form to show up. I think its either an issue with the GET function at the top or the link down at the bottom. Please help! <?php // If the user wants to add a joke $_GET['addjoke'] = $addjoke; if (isset($addjoke)): ?> <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST> <P>Type your joke he <BR> <TEXTAREA NAME="joketext" ROWS=10 COLS=40 WRAP> </TEXTAREA><BR> <INPUT TYPE=SUBMIT NAME="submitjoke" VALUE="SUBMIT"> </FORM> <?php else: // Connect to the database server $dbcnx = @mysql_connect("servername", "username", "password"); if (!$dbcnx) { echo( "<P>Unable to connect to the " . "database server at this time.</P>" ); exit(); } // Select the jokes database if (! @mysql_select_db("jhodara2") ) { echo( "<P>Unable to locate the joke " . "database at this time.</P>" ); exit(); } // If a joke has been submitted, // add it to the database. $joketext = $_POST['joketext']; $submitjoke = $_POST['submitjoke']; if ("SUBMIT" == $submitjoke) { $sql = "INSERT INTO jokes SET " . "JokeText='$joketext', " . "JokeDate=CURDATE()"; if (mysql_query($sql)) { echo("<P>Your joke has been added.</P>"); } else { echo("<P>Error adding submitted joke: " . mysql_error() . "</P>"); } } echo("<P> Here are all the jokes " . "in our database: </P>"); // Request the text of all the jokes $result = mysql_query( "SELECT JokeText FROM jokes"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } // Display the text of each joke in a paragraph while ( $row = mysql_fetch_array($result) ) { echo("<P>" . $row["JokeText"] . "</P>"); } // When clicked, this link will load this page // with the joke submission form displayed. echo("<P><A HREF='$PHP_SELF?addjoke=1'>Add a Joke!</A></P>"); endif; ?> see the problem live at http://www.freewaycreative.com/insert2.php Is it possible to add a query string for example some_var=jk84 to any sort of link be it, http://www.website.com , http://www.website.com/?some_id=4, or http://www.website.com/post=45&category=9 or http://www.website.com/somepost/ ? While adding that extra query string how can I make sure I'm not affecting the website's content or causing some script error? I have seen forums highlight what we searched on google to get to their site. is there a script that would allow me do the same??? Hello everyone. I have a small problem. I might receive a ?aff=## or not on the end of my url when I get a visitor to my website. This depends on if they are sent from a affiliate website or not. If they are it shows fine on the home page but I loss it if they go to another page on my website. I need to keep this ?aff=## information while they look at the other pages. How would I capture and pass this information to my other pages as they surf my site? I tried this to no avail. $aff=$_GET['aff']; I have no clue no adding it back to the next page they go to. Any ideas would be helpful.. Hey all, When someone clicks a link, link looks like this: http://site/homes/edit/1?image=true Now on the same page, I have another link, which posts to the edit method as well, but no query string passed: http://site/homes/edit/1 I want to check if image key is set to true and basd on that, determine which view to render for the user, that is, whether to display the edit form to edit post or the image form to edit image. But by using the get array to try to grab query string: Code: [Select] if($_GET["image"]=="true"){ I get the following error: Message: Undefined index: image It appears that $_GET is not successfully grabbing the parameter. Thanks for response.
this is what i want in the url
when this link is clicked
but i keep getting this error: appreciate any help Hello!
I'm hoping this makes sense.
Basically I have this code:
What it does
1) Looks at the XML
2) Looks for the PIN number in the URL, then finds it in the XML
3) Returns values for the PIN number (which is a profile) allowing me to do echo statements like name, tools, description, etc.
<?php if (!empty($_GET['pin'])) { $feedURL = 'http://www.inveroak.co.uk/readerimages/livepanel/91255.xml'; $showOpsWithNoPics = false; try { $xml = simplexml_load_file($feedURL . '?' . time()); $readers = $xml->xpath('/ReaderDetails/Reader[Pin="' . $_GET['pin'] . '"]'); foreach ($readers as $reader) { if ($reader->Picture == 'None' && $showOpsWithNoPics == false) { $picture = ''; } elseif ($reader->Picture == 'None' && $showOpsWithNoPics == true) { $picture = 'images/defaultpic.jpg'; } else { $picture = $reader->Picture; } if ($picture != '') { $name = $reader->Name; $pin = $reader->Pin; $status = $reader->Status; $description = $reader->Description; $arr_skills = ''; $arr_subjects = ''; foreach ($reader->Categories->Category as $Category) { foreach ($Category->Skill as $Skill) { switch ($Category['name']) { case 'Skills': $arr_skills .= "<li>$Skill</li>"; break; case 'Subjects': $arr_subjects .= "<li>$Skill</li>"; break; } } } $arr_shift = ''; $hourWidth = 20; $PreviousDate = ""; foreach ($reader->Rota->Shift as $Shift) { $Date = $Shift['Date']; $Day = date("l", strtotime($Date)); $Start = $Shift['Start']; $Stop = $Shift['Stop']; if($Stop == '23:59:59' || $Stop == '00:00:00' ){$Stop = '24:00:00';} $Left = date("H",strtotime($Date.' '.$Start)) * $hourWidth; $Width = (round(abs(strtotime($Date.' '.$Stop) - strtotime($Date.' '.$Start)) / 60,2)/60)*$hourWidth; $compare = strcmp ($PreviousDate, $Date); if ($compare != 0) { if ($PreviousDate != '') { //this is not the first loop so close off the previous dayrow and hours divs $arr_shift.= '</div></div>'; } //create a new day row $arr_shift .= '<div class="dayrow">'; $arr_shift .= '<div class="day">'.$Day.'</div>'; $arr_shift .= '<div class="hours">'; } //add the shift object $arr_shift .= '<div class="shift" title="'. substr($Start,0,5).'-'.substr($Stop,0,5) .'" style="left:'.$Left.'px; width:'.$Width.'px; opacity: 1;"></div>'; //set previouse date to the current shift's date so that we can check if we need to create a new day row next loop $PreviousDate = $Date; } //now we have finshed looping the shifts, either close the last div or display a message to show //we have no schedule for the op if ($Date != "") { $arr_shift.= '</div></div>'; } else { $arr_shift.= 'We are sorry but they have not scheduled their hours this week. Email for further details.'; } } } } catch (Exception $e) { echo 'cannot display operator profile'; } } ?>What I am want to achieve 1) Looks at the XML 2) Looks for a set PIN number in the CODE, then finds it in the XML 3) Returns values for the PIN number (which is a profile). Hi, When I run the following code... <?php if ($_GET['view']) { echo 'test'; } .. and then navigate to index.php?view=1 the above code outputs 'test', as intended. The same goes for any non-zero value after the ?view= However, navigating to index.php?view=0 does not work as intended because it assumes that the 0 is FALSE. So if I modify the code, like this: <?php if ($_GET['view'] || $_GET['view'] == 0) { echo 'test'; } ... it outputs 'test' even when view is not set, i.e. when I navigate to index.php without the ?view=. Is there an easy way to force the value to behave as an integer instead of boolean? I have tried putting (int) before, as well as the intval() function, but neither seem to work. Thanks. Hi, i have a query string id=5&start=0 that i want to remove from the url and return the url without it. I am searching a cleaner way for doing it. Here is an example :
Before : http://www.example.com/?a=3&id=5&start=0 After : http://www.example.com/?a=3 Before : http://www.example.com/?id=5&start=0 After : http://www.example.com/ Before : http://www.example.com/?alpha=1&id=5&start=0&beta=2 After : http://www.example.com/?alpha=1&beta=2Thank you Edited by Dareros, 11 August 2014 - 04:06 PM. i want to change this code : $result = mysql_query("select count(*) from 3gp where category='Bollywood'"); with this $result = mysql_query("select count(*) from 3gp where category='$category'"); but i am getting error message "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/funxy/public_html/salmobile.info/3gp-videos.php on line 151". I am calling the page using http://abc.com/3gp-videos.php?category=Bollywood Please help. Code: [Select] <?php $db="funxy_db"; $conn = mysql_connect("localhost","funxy_saba","myasco001"); @mysql_select_db($db) or die( "Unable to select database, Please contact your administrator"); class Pager { function getPagerData($numHits, $limit, $page) { $numHits = (int) $numHits; $limit = max((int) $limit, 1); $page = (int) $page; $numPages = ceil($numHits / $limit); $page = max($page, 1); $page = min($page, $numPages); $offset = ($page - 1) * $limit; $ret = new stdClass; $ret->offset = $offset; $ret->limit = $limit; $ret->numPages = $numPages; $ret->page = $page; return $ret; } } // get the pager input values $page = $_GET['page']; $limit = 3; $result = mysql_query("select count(*) from 3gp where category='Bollywood'"); $total = mysql_result($result, 0, 0); // work out the pager values $pager = Pager::getPagerData($total, $limit, $page); $offset = $pager->offset; $limit = $pager->limit; $page = $pager->page; // use pager values to fetch data $query = "select * from 3gp where category='Bollywood' order by id DESC limit $offset, $limit"; $result = mysql_query($query); // use $result here to output page content //my addition //grab all the content //Custom Table Stsrt// $cols = 4; //number of coloms $i =1; echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\" id=\"table1\" bordercolor=\"#FFFFFF\" bgcolor=\"#FFFFFF\">" ."<tr>"; while($r=mysql_fetch_array($result)) { //the format is $variable = $r["nameofmysqlcolumn"]; //modify these to match your mysql table columns $id=$r["id"]; $name=$r["name"]; $views=$r["views"]; $url=$r["url"]; $image=$r["image"]; $category=$r["category"]; //display the row $mybox = " <br> <a href='http://salmobile.info/3gp-videos-download.php?id=$id' class=\"classd\"><b><u> $name</u></b></a> <BR> <span class=\"text\"><img src=\"$image\" width=\"60\" height=\"60\"></span> <BR> <span class=\"text2\">Download This 3GP Video</span> <br>"; if (is_int($i / $cols)){ echo "<td width='336' align='center' style=\"border-style: dotted; border-width: 0\">$mybox</td></tr><tr>"; }else{ echo "<td width='336' align='center' style=\"border-style: dotted; border-width: 0\">$mybox</td>"; } if ( $i / $cols == 3) echo "<td colspan='3' align=\"center\"> </td></tr><tr>"; if ( $i / $cols == 8) echo "<td colspan='3' align=\"left\"> </td></tr><tr>"; $i++; //end if }//end while echo "</tr></table>"; //Custom Table End// //ends my addition // output paging system (could also do it before we output the page content) if ($page == 1) // this is the first page - there is no previous page echo "<font color=\"#FFB300\">Previous</font>"; else // not the first page, link to the previous page echo "<a href=\"http://salmobile.info/index-" . ($page - 1) . ".html\" id=\"navigationURL\"><font color=\"#FFB300\">Previous</font></a>"; for ($i = 1; $i <= $pager->numPages; $i++) { echo " <font color=\"#FFFFFF\">|</font> "; if ($i == $pager->page) echo "<font color=\"#FFB300\"> $i</font>"; else echo "<a href=\"http://salmobile.info/index-$i.html\" id=\"navigationURL\"> <font color=\"#FFB300\">$i</font></a>"; } if ($page == $pager->numPages) // this is the last page - there is no next page echo "Next"; else // not the last page, link to the next page echo " <a href=\"http://salmobile.info/index-" . ($page + 1) . ".html\" id=\"navigationURL\"><font color=\"#FFB300\">Next</font></a>"; ?> Thanks in advance for help. I have a PHP script that has a function called traverseXMLNodes and it passes an xml string. I want anyone with a username and password to be able to call this function from his website or application or programming. In short i want my site to act as an API(Application Programming Interface). I am really stuck as to how to go about this. There are other functions i would like to call as well so traverseXMLNodes is not the only function i want to my "API" users to access. Below is the code I am using. the filename for my php i called remote.php. I am using the following query string to test and no results are returned. http://localhost/testfolder/remote.php?xmlstring=20 Code: [Select] <?php $allowedfuncs = array('xmlstring','remotefunction2'); if(in_array($_get['xmlstring'], $allowedfuncs)) { $func = $_get['xmlstring']; $output = traverseXMLNodes($func); // This calls $_get['funccall']() echo $output; } else { exit(); } function traverseXMLNodes ($func) { echo "The XML string is"; echo "<br/>"; echo $func; echo "<br/>"; } /* More functions go here */ ?> hey @requinix, I know you and I have talked about this before but I just want to clarify this issue. Sadly, I have produced very few websites that have made use of dynamics in the form of database querying. But, the next project that I'm looking at will require it. The last thing I did with a query string involved the recording of downloads of file on a website. and on the page, I had this code: The archive is located he <a href="dl.php?f=archive.zip">archive.zip</a> and the ''dl'' page had this code: if(!$_GET['f']) error('Missing parameter!'); $stmt = $conn->prepare("INSERT INTO tblDownloads (ip, file, date, time) VALUES (?, ?, ?, ?)"); $stmt->bind_param("ssss", $ip, $file, $date, $time); $stmt->execute(); $stmt->close(); $conn->close(); header("Location: archive.zip"); exit; and all the variables in the above ''dl'' page are declared in a file that is required by it, called ""conn.php"". My question for anyone here is: I am going to be producing a website similar to the testing site called ""jsFiddle"": https://jsfiddle.net/ . And it is slated to have a huge amount of content on it. for example, a main page might have 100 links on it whereby, if a user clicks on any of them, it should take them to another page (or load async content) that illustrates and example of any given issue being asked about. So, I know we've talked about $_GET before Requinix, and how most websites use it to produce dynamic content. And we've also talked about the concept of markdown. But once again, can someone here remind me....what's the best way to go about doing this? Storing the actual ""answer to the issue"" content in a backend database and pulling/displaying it appropriately, kind of like what I am showing I did with the file in the above code? thanks. Adam Edited September 6, 2020 by ajetrumpetI want the page to refresh on with the query string, but this isn't working for me... Code: [Select] header("Location: " . $_SERVER['php_self'] . "?" . $_SERVER['query_string'] ); |