PHP - Simple $_get['id'];
Hey all, I'm working on a Market script for my game site but I've came across an Error..
Market.php: <?php session_start(); include ("includes/config.php"); include ("includes/functions.php"); logincheck(); // Grab the Users information. $userinfo = "SELECT * FROM users WHERE username = '$username' LIMIT 1"; $userinfos = mysql_query($userinfo) or die ("Error in Query: Line 11" . mysql_error()); $fetchuser = mysql_fetch_object($userinfos); // Grab the users Garage so they can add Cars onto the Market.. $usergarage = "SELECT * FROM garage WHERE owner = '$username' LIMIT 1"; $usergarages = mysql_query($usergarage) or die ("Error in Query: Line 17" . mysql_error()); $garageuser = mysql_fetch_object($usergarages); // If they want to view the Cars stats: if (strip_tags($_GET['vcstats'])){ $vcstats = strip_tags($_GET['vcstats']); $marketqu = "SELECT * FROM market WHERE type = 'car'"; $doqut = mysql_query($marketqu) or die ("Error in Query: Line 186: " . mysql_error()); $objmarket = mysql_fetch_object($doqut); $caridfrommarket = $objmarket->carid; $getthecar = "SELECT * FROM garage WHERE id='$caridfrommarket' LIMIT 1"; $carinfo = mysql_query($getthecar) or die ("Error in Query: Line 192 " . mysql_error()); $carstats = mysql_fetch_object($carinfo); $cid = $carstats->id; $mph = $carstats->mph; $fuel = $carstats->fuel; $value = $carstats->value; $currentowner = $carstats->owner; $nameofcar = $carstats->car; $miles = $carstats->miles; $pic = $carstats->pic; // Lets show the Stats $nos = $carstats->nos; $engine = $carstats->engine; $transmission = $carstats->transmission; $exhaust = $carstats->exhaust; $breaks = $carstats->brakes; $suspension = $carstats->suspension; // Accessiours side $body = $carstats->body; $interior = $carstats->interior; $amp = $carstats->amp; $alloys = $carstats->alloys; $neons = $carstats->neons; $taillights = $carstats->taillights; // Showing the Table in which it will display the Car Information on. echo ("<table width='50%' cellpadding='0' cellspacing='0' border='1' align='center' class='table'> <tr> <td class='header' align='center' colspan='4'>".$nameofcar." (".$cid.")</td> </tr> <tr> <td colspan='4' align='center'><img src='".$pic."'></img> </td> </tr> <tr> <td class='omg' colspan='4'>Performance</td> </tr> <tr> <td>Nos:</td><td>".$nos."</td><td>Engine:</td><td>".$engine."</td> </tr> <tr> <td>Transmission:</td><td>".$transmission."</td><td>Exhaust:</td><td>".$exhaust."</td> </tr> <td>Breaks:</td><td>".$breaks."</td><td>Suspension:</td><td>".$suspension."</td> </tr> <tr> <td colspan='4' class='omg'>Accessorys:</td> </tr> <tr> <td>Body:</td><td>".$body."</td><td>Interior:</td><td>".$interior."</td> </tr> <tr> <td>Amp:</td><td>".$amp."</td><td>Alloys:</td><td>".$alloys."</td> </tr> <tr> <td>Neons:</td><td>".$neons."</td><td>Taillights:</td><td>".$taillights."</td> </tr> <tr> <td>Miles:</td><td>".number_format($miles)."</td><td>Value:</td><td>".$value."</td> </tr> <tr> <td>Fuel:</td><td>".$fuel."</td><td>MPH:</td><td>".$mph."</td> </tr> <tr> <td class='omg'>Owner:</td><td class='omg'><a href='profile.php?viewuser=".$currentowner."'>".$currentowner."</a></td><td class='omg'>Worth:</td><td class='omg'>£".number_format($value)."</td> </tr> </table> <br />"); // Continue soon, lets get the things showing like the Table first! } ?> <form action="" method="GET" name="TheForm"> <table width="50%" cellpadding="0" cellspacing="0" border="1" align="center" class="table"> <tr> <td class="header" align="center" colspan="5">Cars For Sale</td> </tr> <tr> <td>Car Name:</td><td>View Stats:</td><td>Price:</td><td>Buy It Now:</td><td>Cancle</td> <tr> <?php $carsforsale = mysql_query ("SELECT * FROM market WHERE type = 'car'") or trigger_error ("Error in Query: 329 Line " . mysql_error()); while ($cfs = mysql_fetch_object($carsforsale)){ $number = mysql_num_rows($carsforsale); $priceofauc = $cfs->startingprice; // An seller of the car: if ($username == $cfs->owner){ $calowner = "<a href='?cauction=$cfs->id'>Cancle Auction</a>"; } $newid = $cfs->carid; // Lets attempt to get the Cars name rather than the ID. $carnameis = "SELECT * FROM garage WHERE id = '$newid'"; $namecar = mysql_query($carnameis) or die ("Error in Query: Line 255 " . mysql_error()); $aye = mysql_fetch_object($namecar); $Testingthis = $cfs->carid; echo ('<td>'.$aye->car.'</td><td><a href="?vcstats='.$aye->id.'">View Stats</a></td><td>£'.number_format($priceofauc).'</td><td><a href="?buyitnow='.$cfs->id.'">Buy It Now</a></td><td>'.$calowner.'</td></tr><tr>'); } ?> </td> </tr> </table> </form> <br /> In that part of the code, I've tried coding it so when the click the link displaying the Car for sale it will show them the car stats , although... When they do click on the "View Stats" link it only displays the car stats which is on top of the list. For Example: Car Name: || View Stats: || Buy it now: || ID: || Cancle ---------------------------------------------------------------- Evo : || ViewStats || Buy it now || 1 || Cancle Mini : || ViewStats || Buy it now || 2 || Cancle So on that example with my code working how it is now it would only show the Stats for the Evo which has the ID of 1 even if the Mini (ID 2) is clicked. Is there something I've done wrong in my code which is making it only show the top cars stats? Thanks for any help given Similar TutorialsHi I have written a simple bit of code, i used to code php a little and have just decided to start coding php again but for the life of me can't work out why this isn't working, so if someone could help this would be great. address www.mysite.co.uk/index.php?vid=video2 <php if (isset($_GET['vid'])){ $video=$_GET['vid']; }else{ $video="video1"; } when i echo $video i only get video=1 The code below works echo '<script language="javascript">'; echo 'top.location.href = "/breaking-news/bsnewsstorygoeshere/";'; echo '</script>'; this also works echo '<script language="javascript">'; echo 'top.location.href = "http://anywebsite.com";'; echo '</script>'; the problem, is I have a URL listed in a url variable that can be retreived via $_GET['url'] my question is how to get that variable into the above code? I've tried echo '<script language="javascript">'; echo "top.location.href = \"$_GET['url']\";"; echo '</script>'; but that doesnt seem to work, can anyone advise? 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 do i get the id from the url so i can use it 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>'; ?> 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 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? 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] 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> 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 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 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. 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. 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. 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!! Please i will like to know what this variable $_GET['id']is used for and how to use it Thanks I run into this every now and again and wonder if someone knows what I could be doing wrong. Using a simple $ClientID = $_GET['ID']; is not working on a certain page, I can see the ID=193 value in the address field but $ClientID remains an empty variable. I even try $_REQUEST instead, still nothing. I'm puzzled. |