Jump to content

[SOLVED] how i inserted table


saad|_d3vil

Recommended Posts

i have another table in my sql database the table name is albums now how i inserted table when some on click on this url http://www.apnimuskaan.com/sadasdas.php?id=1 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']))
{
    echo 'Your have requested ID #'.$GET['id'].'<br />';
    echo '<a href="sadasdas.php">Back</a>';
}
// no id requested, display results
else
{

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

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

 

Link to comment
https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/
Share on other sites

This is a repost man.

 

Stop using [/url].

 

if (isset ($_GET['id']) && is_numeric ($_GET['id']))

{

  $id = mysql_real_escape_string ($_GET['id']); // paranoia

 

  $sql = "SELECT * FROM album

            WHERE id=".mysql_real_escape_string ($id);

}

 

Dunno if this is what you need.

I think you need something like 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']))
{
$id = $GET['id'];
echo 'Your have requested ID #'.$id.'';
echo '<a href="sadasdas.php">Back[/url]';
$result = mysql_query("SELECT * FROM table2
    		       WHERE id=$id");
while($row = mysql_fetch_array($result))
{
	echo $row['row1'];
	echo $row['row2'];
}

}
// no id requested, display results
else
{

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

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

 

but without knowing the structure of your second table I cannot help any further

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.