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

Link to comment
Share on other sites

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

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.