Jump to content


Photo

nublet in need of help


  • Please log in to reply
8 replies to this topic

#1 liquidfire

liquidfire
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 19 October 2006 - 12:09 PM

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 ..

#2 ruano84

ruano84
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationVenezuela

Posted 19 October 2006 - 12:18 PM

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
Alexis RR

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 19 October 2006 - 12:57 PM

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:
<?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!";
?>

good luck!
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 liquidfire

liquidfire
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 19 October 2006 - 03:19 PM

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 error


Parse 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


#5 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 19 October 2006 - 03:40 PM

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 ;)
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#6 liquidfire

liquidfire
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 19 October 2006 - 03:42 PM

lol sorry ok  here is the whole code.. prob noobish how i did everything but oh well i tryed


<?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>';
   
?>


#7 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 19 October 2006 - 04:12 PM

your error is that in line 2, you are referencing an array key with quotes inside of the double quotes. here are a few ways you can fix it:
<?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
}
?>

hope this helps
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#8 liquidfire

liquidfire
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 19 October 2006 - 04:28 PM

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 !

#9 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 19 October 2006 - 05:16 PM

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 !


hehe... that's what we're here for! ;)
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users