Jump to content

View more info....... Help


HaZaRd420

Recommended Posts

So Ive made my roster page. It displays only 3 things from the database which are, Name, handle and location . Then I have a link that says View.

- The view is to view there profile.

I Dont know how to set it up to where I can click on that view and it will select the right id and show the remaining information like computer specs ect.. Thanks for your time.

 

Link to comment
Share on other sites

if your db has an id field, (if not best to make one and index), pull id with your other results and in your links do somthing similar to

 

echo "<a href=\"?view=".$result[id]."\">View</a>";

 

if you need more please post your source. :)

Link to comment
Share on other sites

Heres my code. I tried it. and nothing came up all that gets added to the url is view=  / and the page i have the rest of the info on is info.php

<?

mysql_connect("localhost","#","#"); 


mysql_select_db("noob_roster"); 


$result = mysql_query("select * from roster ORDER BY handle DESC LIMIT 20");

while($r=mysql_fetch_array($result))
{	
  
  
   $handle=$r["handle"];
   $name=$r["name"];
   $location=$r["location"];
   $id=$r["id"];
   
  
   echo "<tr style=\"background: #ffffff; padding: 2px; color:#1c1c1c;\">
<td style=\"border: 1px solid #ffffff;\">$handle</td>
<td style=\"border: 1px solid #ffffff;\">$name</td>
<td style=\"border: 1px solid #ffffff;\">$location</td>
<td style=\"border: 1px solid #ffffff;\"><a href=\"?view=".$result[id]."\">View</a></td>
</tr>";
}
?>

Link to comment
Share on other sites

mysql_connect("localhost","#","#");

 

mysql_select_db("noob_roster");

 

$result = mysql_query("select * from roster ORDER BY handle DESC LIMIT 20");

 

while($r=mysql_fetch_array($result))

{

 

  $handle=$r["handle"];

  $name=$r["name"];

  $location=$r["location"];

  $id=$r["id"];

 

  echo "<tr style=\"background: #ffffff; padding: 2px; color:#1c1c1c;\"> 

  <td style=\"border: 1px solid #ffffff;\">$handle</td>

  <td style=\"border: 1px solid #ffffff;\">$name</td>

  <td style=\"border: 1px solid #ffffff;\">$location</td>

  <td style=\"border: 1px solid #ffffff;\"><a href=\"?view=".$id."\">View</a></td>

  </tr>";

}

 

just a change of variable name is all :)

Link to comment
Share on other sites

Here is the page I want to link it to. Is this the Output?

 

<? include("header.php") ?>
<table width="100%" cellspacing="0px" cellpadding="0px">
<tr class="newstop">
<td class="news">
TEAMROSTER <br />
<td class="news2">Category: Roster</td>
</tr>
<tr>
<td colspan="100%" class="newstext">
<center>
<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("#","#","#"); 

//select which database you want to edit
mysql_select_db("#"); 

//select the table
$result = mysql_query("select * from roster");

//grab all the content
while($r=mysql_fetch_array($result))
{	
   //the format is $variable = $r["nameofmysqlcolumn"];
   //modify these to match your mysql table columns
  
   $handle=$r["handle"];
 $img=$r["img"];
   $name=$r["name"];
 $exp=$r["exp"];
   $location=$r["location"];
 $config=$r["config"];
 $manufacture=$r["manufacture"];
 $cpu=$r["cpu"];
 $videocard=$r["videocard"];
 $memory=$r["memory"];
 $monitor=$r["monitor"];
 $headphones=$r["headphones"];
 $keyboard=$r["keyboard"];
 $mouse=$r["mouse"];
   $id=$r["id"];
   
   //display the row
   echo "

 <table width=\"100%\" cellspacing=\"2px\" cellpadding=\"2px\">
 <tr>
 <td colspan=\"100%\"><center><img src=\"$img\" width=\"83px\" height=\"101px\"></td>
 </tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >Handle</td>
<td class=\"menutext\">$handle</td>
</tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >Name</td>
<td class=\"menutext\">$name</td>
</tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >Experience</td>
<td class=\"menutext\">$exp</td>
</tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >Location</td>
<td class=\"menutext\">$location</td>
</tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >Config</td>
<td class=\"menutext\">$config</td>
</tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >Manufacture</td>
<td class=\"menutext\">$manufacture</td>
</tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >CPU / Processor</td>
<td class=\"menutext\">$cpu</td>
</tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >VideoCard</td>
<td class=\"menutext\">$videocard</td>
</tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >Memory</td>
<td class=\"menutext\">$memory</td>
</tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >Monitor</td>
<td class=\"menutext\">$monitor</td>
</tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >Headphones</td>
<td class=\"menutext\">$headphones</td>
</tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >Keyboard</td>
<td class=\"menutext\">$keyboard</td>
</tr>
<tr style=\"font-size: 11px;\">
<td bgcolor=\"#000000\" width=\"45px\" class=\"menutop\" >Mouse</td>
<td class=\"menutext\">$mouse</td>
</tr>
</table>


 ";
}
?><br />
<center>
- - <a href="index.php?id=roster">Take me back!</a> - -
</td>
</tr>
</table>

<? include("footer.php") ?>

Link to comment
Share on other sites

The output is the page after it's loaded.  You can right click on the page( or go to your browsers menu bar ) and find "View Source".  We're asking if when you view source on the page that you said isn't working, does it have the links formatted correctly?

 

So you might see:

<td style=\"border: 1px solid #ffffff;\"><a href=\"?view=1">View</a></td>

 

If it has the links working correctly, you will see things like that with the corresponding IDs in your database.

Link to comment
Share on other sites

So now on your view page you can add:

if(isset($_GET['view'])){
  $id = intval($_GET['view']);
}else{
  $id = 1;
  echo 'No id specified, showing first user.';
}

^-- somewhere before the mysql_query();

 

And change your query to be:

$result = mysql_query("select * from roster WHERE id='$id'");

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.