liquidfire Posted October 19, 2006 Share Posted October 19, 2006 ok i have i tried everything i can think of so i though of why not ask someone else so here i am, and im sure this is noobish question ....Ok i have this page "clans.php" which runs a query to get Clannames out my data base. im needing to link the clan names with thier id *they are in the data base and auto inc.* but i cant figure out how to link clans.php to the next page (Display.php) and display the infor that is needed for the selected clan the display page has this query include('global_connect.php');$info = mysql_query("SELECT * FROM Clans WHERE ID = $_GET['ID']");$data = mysql_fetch_array($info); echo but im lost on how i should do my $_GET['ID'] for this .. any help would be great.. you can slap the nublet around a few times if you like .. Quote Link to comment Share on other sites More sharing options...
ruano84 Posted October 19, 2006 Share Posted October 19, 2006 Hi,I dont know exactly what you need , but in the clans.php there must be a form like this:<form method="post" action="Display.php"><input type="text" name="ID"><input type="Submit" name="submit"></form>If i'm wrong, why don't you explain yourself a little better?Alexis RR Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 19, 2006 Share Posted October 19, 2006 basically, you want to use the results of your query to create hyperlinks to your second page. the $_GET['ID'] in the display page is looking for something like "?ID=564" at the end of your URL, so you simply have to put it there. here is some sample code you can modify for your use in clans.php:[code]<?php$sql = mysql_query("SELECT * FROM clansTable ORDER BY clanName");if (mysql_num_rows($sql) > 0) { while ($x = mysql_fetch_array($sql)) { $id = $x['id']; $name = $x['name']; echo "<a href=\"Display.php?ID=$id\">$name</a><br />\n"; }} else echo "No clans to display!";?>[/code]good luck! Quote Link to comment Share on other sites More sharing options...
liquidfire Posted October 19, 2006 Author Share Posted October 19, 2006 ok i changed the code to this thinking it should work <?php include('global_connect.php');$sql = mysql_query("SELECT * FROM Clans");if (mysql_num_rows($sql) > 0) { while ($x = mysql_fetch_array($sql)) { $id = $x['ID']; $name = $x['Clanname']; echo "<a href=\"display.php?ID=$id\">$name</a><br />\n"; }} else echo "No clans to display!";?> i fell the (mysql_num_rows is not quite what i need i keep getting this errorParse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/ldsliqui/public_html/clan_test/display.php on line 3 Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 19, 2006 Share Posted October 19, 2006 is that your entire code? it's throwing a syntax error, meaning that somewhere in the actual code, there's something amiss. which is line 3 in your code?also, it would be helpful if you would place your code within [ code ] blocks, too ;) Quote Link to comment Share on other sites More sharing options...
liquidfire Posted October 19, 2006 Author Share Posted October 19, 2006 lol sorry ok here is the whole code.. prob noobish how i did everything but oh well i tryed[code]<?php include('global_connect.php');$info = mysql_query("SELECT * FROM Clans WHERE ID = $_GET['ID']");$data = mysql_fetch_array($info); echo '<html><head><title>'. $data["claname"] .'</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link href="Layout.css" rel="stylesheet" type="text/css"></head><body bgcolor="#333333"><div class="content"> <div class="name"> <div align="center">'. $data["claname"] .'</div></div> <div class="nav"><a href="#" class="nav_link" >Main</a><br><a href="#" class="nav_link" >About Clan</a><br><a href="#" class="nav_link">Members</a><br><a href="#" class="nav_link">Skrimish</a><br><a href="#" class="nav_link">Clan Wars</a></div><div class="page"> <p>'. $data["about"] .' </p> </div></div><span class="clan_info"><p>Clan Rankings<br> Ranks :<br>Wins:<br>Kills:<br>Deaths : </p></span></body></html>'; ?>[/code] Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 19, 2006 Share Posted October 19, 2006 your error is that in line 2, you are referencing an array key [i]with quotes[/i] inside of the double quotes. here are a few ways you can fix it:[code]<?php// change this line:$info = mysql_query("SELECT * FROM Clans WHERE ID = $_GET['ID']");// to this:$info = mysql_query("SELECT * FROM Clans WHERE ID = $_GET[ID]");// or this:$info = mysql_query("SELECT * FROM Clans WHERE ID = {$_GET['ID']}");// or this:$info = mysql_query("SELECT * FROM Clans WHERE ID = " . $_GET['ID']);// however, i would recommend you check to make sure that the ID variable is set before// you call it, so that nobody can break your page by hitting the display.php page directly:if (isset($_GET['ID'])) { $info = mysql_query("SELECT * FROM Clans WHERE ID = $_GET[ID]"); // run the rest of your script here} else { // ID is not set, redirect to your listing page again}?>[/code]hope this helps Quote Link to comment Share on other sites More sharing options...
liquidfire Posted October 19, 2006 Author Share Posted October 19, 2006 Thanks very much i go it working now ! you are awesome. lol anything i can do to make it up to you lol thanks alot ! Quote Link to comment Share on other sites More sharing options...
obsidian Posted October 19, 2006 Share Posted October 19, 2006 [quote author=liquidfire link=topic=112009.msg454494#msg454494 date=1161275282]Thanks very much i go it working now ! you are awesome. lol anything i can do to make it up to you lol thanks alot ! [/quote]hehe... that's what we're here for! ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.