Jump to content

[SOLVED] how i make page for each id


saad|_d3vil

Recommended Posts

Hi all see this website http://www.apnimuskaan.com/sadasdas.php in this site click on any link it show same page how i change the page of id . I want to know how i make page for id1 and how i make page for id2 my php code is this

<?php
$con = mysql_connect("localhost","apnimusk","password");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }

mysql_select_db("apnimusk_naat", $con);

// check to see if id is set
if(isset($_GET['id']) && is_numeric($_GET['id']))
{	
$result = mysql_query("SELECT * FROM albums");
echo "<table border='1'>
<tr>
<th>Title</th>
</tr>";
while($row = mysql_fetch_array($result))
{
 echo "<tr>";
 echo "<td>" . $row['title'] . "</td>";
 echo "</tr>";	
 }
echo "</table>";
}
// no id requested, display results
else
{

$result = mysql_query("SELECT * FROM album");

echo "<table border='1'>
<tr>
<th>Name</th>
<th>Age</th>
</tr>";

while($row = mysql_fetch_array($result))
 {
 echo "<tr>";
 echo "<td>" . $row['name'] . "</td>";
 echo "<td>" ."<a href='?id=".$row['id']."'>".$row['age']."</a>" . "</td>";
 echo "</tr>";
 }
echo "</table>";
}
mysql_close($con);
?>

Link to comment
https://forums.phpfreaks.com/topic/121726-solved-how-i-make-page-for-each-id/
Share on other sites

<?php
$con = mysql_connect("localhost","apnimusk","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("apnimusk_naat", $con);

// check to see if id is set
if(isset($_GET['id']) && is_numeric($_GET['id']))
{	
$result = mysql_query("SELECT * FROM `albums` WHERE `id` = '".$_GET['id']."'");
echo "<table border='1'>
<tr>
<th>Title</th>
</tr>";
while($row = mysql_fetch_array($result))
{
  echo "<tr>";
  echo "<td>" . $row['title'] . "</td>";
  echo "</tr>";	
  }
echo "</table>";
}
// no id requested, display results
else
{

$result = mysql_query("SELECT * FROM `album`");

echo "<table border='1'>
<tr>
<th>Name</th>
<th>Age</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['name'] . "</td>";
  echo "<td>" ."<a href='?id=".$row['id']."'>".$row['age']."</a>" . "</td>";
  echo "</tr>";
  }
echo "</table>";
}
;
}
mysql_close($con);

http://www.apnimuskaan.com/sadasdas.php see now . Now how i make another column this is my code

<?php
$con = mysql_connect("localhost","apnimusk","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("apnimusk_naat", $con);

// check to see if id is set
if(isset($_GET['id']) && is_numeric($_GET['id']))
{	
$result = mysql_query("SELECT * FROM albums");
echo "<table border='1'>
<tr>
<th>Title</th>
</tr>";
while($row = mysql_fetch_array($result))
{
  echo "<tr>";
  echo "<td>" . $row['title'] . "</td>";
  echo "</tr>";	
  }
echo "</table>";
}
// no id requested, display results
else
{

$result = mysql_query("SELECT * FROM album
WHERE name='Timmy Mellowman'");


echo "<table border='1'>
<tr>
<th>Name</th>
<th>Age</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['name'] . "</td>";
  echo "<td>" ."<a href='?id=".$row['id']."'>".$row['age']."</a>" . "</td>";
  echo "</tr>";
  }
echo "</table>";
}
mysql_close($con);
?>

mate it is giving erorr

Parse error: syntax error, unexpected '}' in /home1/apnimusk/public_html/sadasdas.php on line 68

in this code

<?php
$con = mysql_connect("localhost","apnimusk","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("apnimusk_naat", $con);

// check to see if id is set
if(isset($_GET['id']) && is_numeric($_GET['id']))



{




$result = mysql_query("SELECT * FROM `albums` WHERE `id` = '".$_GET['id']."'");
echo "<table border='1'>
<tr>
<th>Title</th>
</tr>";



while($row = mysql_fetch_array($result))



{
  echo "<tr>";
  echo "<td>" . $row['title'] . "</td>";
  echo "</tr>";




  }
echo "</table>";



}
// no id requested, display results
else
{

$result = mysql_query("SELECT * FROM `album`");

echo "<table border='1'>
<tr>
<th>Name</th>
<th>Age</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['name'] . "</td>";
  echo "<td>" ."<a href='?id=".$row['id']."'>".$row['age']."</a>" . "</td>";
  echo "</tr>";
  }
echo "</table>";
}
;
}
mysql_close($con);

<?php
$con = mysql_connect("localhost","apnimusk","password");
if (!$con){
die('Could not connect: ' . mysql_error());
}

mysql_select_db("apnimusk_naat", $con);
if(isset($_GET['id']) && is_numeric($_GET['id'])){
$result = mysql_query("SELECT * FROM `albums` WHERE `id` = '".$_GET['id']."'");
echo "<table border='1'>
<tr>
<th>Title</th>
</tr>";
while($row = mysql_fetch_array($result)){
	echo "<tr>";
	echo "<td>" . $row['title'] . "</td>";
	echo "</tr>";
}
echo "</table>";
}else{
$result = mysql_query("SELECT * FROM `album`");
echo "<table border='1'>
<tr>
<th>Name</th>
<th>Age</th>
</tr>";
while($row = mysql_fetch_array($result)){
	echo "<tr>";
	echo "<td>" . $row['name'] . "</td>";
	echo "<td>" ."<a href='?id=".$row['id']."'>".$row['age']."</a>" . "</td>";
	echo "</tr>";
}
echo "</table>";
}
mysql_close($con);
?>

Archived

This topic is now archived and is closed to further replies.

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