Jump to content

nublet in need of help


liquidfire

Recommended Posts

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 ..
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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!
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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
Link to comment
Share on other sites

[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! ;)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.