PHP - Another $_get Question
my index.php file includes different files depending on the get value. all of them work except this one:
elseif (isset($_GET['forum']) && $_GET['child']) { include 'modules/pages/children.php'; } when i point my browser to index.php?forum=1&child=1 it stays on the same page. Do i need to include something else when getting a url with 2 $_GETs? Similar TutorialsI'm a beginner with php, but I have a few nifty things working, and I'm trying to enhance my project to do something at the next level. The project is a library database search tool, and I'm having trouble getting from the search results to the page which shows a record for an individual book. The search tool works well, and works a few different ways, so I feel I should be able to get this, but this is a first attempt.
I'm stuck on where and how to use $_GET. If I understand what I need to do, it's something like this:
My search results page has a link as part of the last column:
My first question is, how do I parse this link in php so that it pulls the Id. number from the database, (so that "Link" points to /book.php?0140441638 as a uri? That column looks something like this:
On the next page, (book.php) which should be the page which shows the information for the individual book, after connecting to my database I have $query="SELECT * FROM MyTable WHERE id='0140441638'". How would I go about passing the '0140441638' from the referring link?
The next question is how to concatenate this with the openlibrary link in the screenshot -- so that it is passed like src='..//covers.openlibrary.org/b/isbn/**RESULT**-L.jpg' />
Thank you to anyone who can help me with this!
This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=342298.0 A few months ago, and a good amount of time before that, I had people telling me to use isset() instead of performing to see if the variable is empty, such as: !$_GET[''] I know the differences in the function and what they do, but when could isset() be used in a situation where it's better/more efficient then: !$_GET[''] I do use isset(), though. how would i get this to work if they have click on the add page and the action is add i want it to do something how would i do it Code: [Select] <?php if(isset($_GET['action'])){ } ?> <a href="pages.php?action=add">Add Page</a> How to find the name value using php or $_GET here is the url header("Location:http://localhost:8666/OnlineBookingsPhp/index.php?name=Next"); Thanks I cannot seem to get my link to work.. I want to build a php script that has more than one $_GET command.. The link I want to make is: index.php?section=tutorial&viewing=18-classes_or_ids. Here is my PHP code.. <?php $section = $_GET['section']; switch ($section) { case "home": include("home.html"); break; case "register": include("register.html"); break; case "tutorial_home": include("tutorial.html"); break; default: include("home.html"); } $tutorial = "?section=" . urlencode('tutorial&viewing') . $_GET['tutorial&viewing']; switch ($tutorial) { case "18-classes_or_ids": include("classesorids.html"); break; } ?> Please help me!! Hi there, I am new to this forum want to say Hi to everyone . I just learn a little bit of PHP. I couldn't figure this out. Could someone please help me? Many thanks. 1. when I ran the 1st code below, it showed me "thank you" in the browser. <?php $title=$_GET[title]; echo $title; ?> 2. when I ran the 2nd code below, I got what I wanted. <?php $sql = "SELECT * FROM mytable WHERE title='thank you' "; ... ?> 3. when I ran the 3rd code below, it showed me a blank page . <?php $title=$_GET[title]; $sql = "SELECT * FROM mytable WHERE title='<?php echo $title; ?>' "; ... ?> How to make the 3rd code work like the 2nd one? It seems a php code under php is NOT working. hi all
new to webforum and php, how can I enter $_get['id] as I know this id...my code snippet is below
$sql = "SELECT x,y,z from tablename WHERE Id='" . $_GET["id"] . "'";
It works fine as it is getting the variable from a another webpage, but I know an id and want to enter it manually just to check a different webpage , thanks in advance....singhy
Please give example if the known id=xyztest
I am seen people have dynamic pages that loads the information from a database and then displays that information from the url. EG domain.com/somedirectory/something I have a website that does this but uses domain.com/something.php?id=something . This works great but when I go to try and get the statistics for that page from facebook for number of people that have liked that page. When I go to: http://graph.facebook.com/http://likebook.cz.cc/ It shows me the information: Code: [Select] { "id": "**************", "name": "LikeBook", "picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs178.ash2/41817_130259343675613_3465_s.jpg", "link": "http://www.facebook.com/pages/LikeBook/130259343675613", "category": "Website", "description": "Collect every like at LikeBook.cz.cc", "fan_count": 3 } But when I try and go to: http://graph.facebook.com/http://likebook.cz.cc/like.php?id=31 It shows me: Code: [Select] { "id": "http://likebook.cz.cc/like.php" } So what I need to do is. Make a dynamic page within that sub directory. So that http://likebook.cz.cc/like/31 does grabs the information from line 31 of my database, like http://likebook.cz.cc/like.php?id=31 would do. Thank you ~AJ I am really confused about how people use $_GET to give a page a link so far what I understand is that $_GET grabs the information from a link So if my link was http://localhost/stargate/users/profile.php?goauld=Sam how do I turn this into viewing Sams profile soon as i type in that link with out having to hit a search button first would really appreciate if someone help me understand this please cause it appears i really need to know how to do this. Code: [Select] <?php if(isset($_POST['search'])) { // searches goaulds then displays them $search3 = "SELECT goauld,id FROM users WHERE goauld='".mysql_real_escape_string($_POST['goaulds'])."'"; $search2 = mysql_query($search3) or die(mysql_error()); WHILE($search1 = mysql_fetch_array($search2)){ $grab_goauld = $search1['goauld']; echo '<table width="300" height="5" border="1" align="center">'; echo '<th><center>Goauld Statistics</center></th>'; echo "<tr><td height='340'>$grab_goauld</td></tr>"; } } echo '</table>'; ?> Please i will like to know what this variable $_GET['id']is used for and how to use it Thanks Hi I am trying to use 2 codes to get a url link. code1 (test.php): <form action="test1.php" method="GET" /> link: <input type="text" name="link" /><br /> <input type="submit" value="Submit" /> </form> code2 (test1.php) <?php $link = $_GET['link']; echo $link; ?> If I input a link as a text such as "Yahoo" it works. But if I input a link as "http://yahoo.com", it didn't work . I have a link (http://site.com/user/redirect). This link directs me to "site.com/user.php?level=site.com/123.php?hp=1" How can I echo just "site.com/123.php?hp=1"? I know how to use $_GET but I don't know how I can apply it to this. I have some javascript for a tabbed interface in index.php. The content of each tab is in content.php which uses $_GET to define which tab is selected. But i want to include queries based on variables from index.php how would i do this? here is the code for the tabbed interface: <script language="JavaScript" type="text/javascript" src="<?php echo SITE_ROOT; ?>/js/ahahLib.js"></script> <script language="JavaScript" type="text/javascript"> function makeactive(tab) { document.getElementById("tab1").className = ""; document.getElementById("tab2").className = ""; document.getElementById("tab3").className = ""; document.getElementById("tab"+tab).className = "active"; callAHAH('includes/content.php?content= '+tab, 'content', 'Loading...', 'Error'); } </script> <ul id="tabmenu" > <li onclick="makeactive(1)"> <a class="" id="tab1">Account Information</a> </li> <li onclick="makeactive(2)"> <a class="" id="tab2">Second Page</a> </li> <li onclick="makeactive(3)"> <a class="" id="tab3">Third Page</a> </li> </ul> <div id="content"></div> and the code in content.php if ($_GET['content'] == 1) { echo 'Content for Page 1'; } if ($_GET['content'] == 2) { echo 'Content for Page 2'; } if ($_GET['content'] == 3) { echo 'Content For Page 3'; } ive tried adding the variable $user_id to the content.php url as follows: callAHAH('includes/content.php?user=$user_id&content= '+tab, 'content', 'Loading...', 'Error'); } but that just brought up an error. Hello can any one help me with this question iv only just started to use the get function like <code> if (isset($_GET['pageID'])){ echo $row['content']; } </code> can any one if me info how to make it safe I am a new programmer. I am working on a personal project for my portfolio, it is a simple blog. I am trying to give the user the ability to delete a blog entry. It works fine, the problem is that when you refresh the page, with out clicking 'delete' the entry is still deleted. $_GET is passing the $id to my function and it is executing. The code I have posted is my effort to fix the problem. How can I connect $_GET to the delete button ? I have tried using a hidden value but this is not working. Any help would be greatly appreciated. AL Code: [Select] // code to display message before deletion if($_GET['T']) { echo("<div style='float:right; width:25%; height:100px; position:absolute; top:150px; right:15%;'>"); echo("<h2>Are you sure you want to delete:<h2>"); echo $_GET['T']; echo("<form method='get' action='?'>"); echo("<input type='submit' name='button' value='Delete'>"); echo("<input type='hidden' name='submit_check' value='1'>"); echo("</form>"); echo("<form action='http://nuke.industry.com/Blogspiracy/UserPage/index.php'>"); echo("<input type='submit' value='Cancel'/>"); echo("</form>"); echo("</div>"); } // code to delete a selected blog entry function delete_blog($id) { global $dbh; $sql = "DELETE FROM tblBlog WHERE tblBlog.id = '$id' LIMIT 1;"; $sth = $dbh->prepare($sql); $sth-> execute(); return; } if (isset($_GET['id']) && ($_GET['submit_check'])) how do I "GET" the hidden value? { $remove = delete_blog($_GET['id']); } [code] I have javascript to load to my div the contents from php files something like this: QueryString is an addon javascript file loaded above so it works.. var get_id = $.QueryString["id"]; switch(get_id){ case 'page1': $('#div').load('php.php'); break; } on php.php when i try to get the $_GET['id']; which is obviously 'page1' it cant display it... i get nothing , i use switch in order to create dynamic div so i can click in my links and just load the divs content thanks. I never really thought about it before, but recently I visited a site with a url like: www.example.com/?OR Which made me wonder how you would go about getting that keyname since it is without a value. Any ideas? how do i get the id from the url so i can use it Well, i have got this code: Code: [Select] <?php header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); ?> <form action="signature.php?user=" .$user. "&img=". $img" method="post"> <input name="user" type="text" /> <select name="img"> <option value="blue">Blue</option> <option value="red">Red</option> <option value="purple">Purple</option> <option value="pink">Pink</option> </select> <?php $user = $_POST['user']; $img = $_POST['img']; ?> <input type="submit" value="Submit" /> <?php //Skill Grabs $order = array("Overall", "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecraft", "Hunter", "Construction", "Summoning", "Dungeoneering"); $user = $_GET['user']; //Change this to the variable (Or a string literal) that contains the username $get = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user"); $get = explode("\n", $get); $i = 0; foreach ($order as $key => $value) { $value = strtolower($value); $temp = explode(",", $get[$i]); $temp = array("rank" => $temp[0], "level" => $temp[1], "exp" => $temp[2]); $stats[$value] = $temp; $eval = "\$$value = array(\$temp[\"rank\"], \$temp[\"level\"], \$temp[\"exp\"]);"; eval($eval); $i++; } //End Skill Grabs // specify the file name - you can use a full path, or "../../" type stuff here // if the image is not in the same directory as this code file $image = imagecreatefrompng("http://slay2day.x10.mx/highscores/signatures/".$_GET['img'].".png"); // specify the font size // in this case, the color is white, but you can replace the numbers with the RGB values // of any color you want $color = imagecolorallocate($image, 255,255,255); // and now we do the overlay - the layers of text start top to bottom, so // the drop shadow comes first // $image - the base image file we specified above // $font_size - Well duh. Its the size of the font // 0 - the angle of the text - we don't want an angle, so we leave it at 0 // 55 - pixels to the right from the leftmost part of the image // 35 - pixels down from the top of the image // $black - the color we defined above // "../fonts/ARIALBD.TTF" - the location on the server that the font can be found // "Test Text" - the text we're overlaying - you can also use a variable here ImageTTFText ($image, "7", 0, 280, 10, $color, "arial.ttf","Slay2day"); ImageTTFText ($image, "12", 0, 240, 55, $color, "biblio.ttf",$user); if($overall[0]==-1){ImageTTFText($image, "11", 0, 230, 105, $color, "biblio.ttf","NOT RANKED");}else{ImageTTFText($image, "11", 0, 240, 105, $color, "biblio.ttf",$overall[0]);} ImageTTFText ($image, "10", 0, 27, 20, $color, "arial.ttf",$attack[1]); ImageTTFText ($image, "10", 0, 27, 42, $color, "arial.ttf",$strength[1]); ImageTTFText ($image, "10", 0, 27, 64, $color, "arial.ttf",$defence[1]); ImageTTFText ($image, "10", 0, 27, 88, $color, "arial.ttf",$hitpoints[1]); ImageTTFText ($image, "10", 0, 27, 114, $color, "arial.ttf",$ranged[1]); ImageTTFText ($image, "10", 0, 70, 20, $color, "arial.ttf",$prayer[1]); ImageTTFText ($image, "10", 0, 70, 42, $color, "arial.ttf",$magic[1]); ImageTTFText ($image, "10", 0, 70, 64, $color, "arial.ttf",$cooking[1]); ImageTTFText ($image, "10", 0, 70, 88, $color, "arial.ttf",$woodcutting[1]); ImageTTFText ($image, "10", 0, 70, 114, $color, "arial.ttf",$fletching[1]); ImageTTFText ($image, "10", 0, 117, 20, $color, "arial.ttf",$fishing[1]); ImageTTFText ($image, "10", 0, 117, 42, $color, "arial.ttf",$firemaking[1]); ImageTTFText ($image, "10", 0, 117, 64, $color, "arial.ttf",$crafting[1]); ImageTTFText ($image, "10", 0, 117, 88, $color, "arial.ttf",$smithing[1]); ImageTTFText ($image, "10", 0, 117, 114, $color, "arial.ttf",$mining[1]); ImageTTFText ($image, "10", 0, 162, 20, $color, "arial.ttf",$herblore[1]); ImageTTFText ($image, "10", 0, 162, 42, $color, "arial.ttf",$agility[1]); ImageTTFText ($image, "10", 0, 162, 64, $color, "arial.ttf",$thieving[1]); ImageTTFText ($image, "10", 0, 162, 88, $color, "arial.ttf",$slayer[1]); ImageTTFText ($image, "10", 0, 162, 114, $color, "arial.ttf",$farming[1]); ImageTTFText ($image, "10", 0, 212, 20, $color, "arial.ttf",$runecraft[1]); ImageTTFText ($image, "10", 0, 212, 42, $color, "arial.ttf",$construction[1]); ImageTTFText ($image, "10", 0, 212, 64, $color, "arial.ttf",$hunter[1]); ImageTTFText ($image, "10", 0, 212, 88, $color, "arial.ttf",$summoning[1]); ImageTTFText ($image, "10", 0, 212, 114, $color, "arial.ttf",$dungeoneering[1]); // Now add the actual white text "on top" header("Content-type: image/png"); imagepng($image); imagedestroy($image); ?> It generates a image and gets data from the name thats in the url. I am wanting to make a form where they fill out their name and what color they use. What is wrong? |