saad|_d3vil Posted August 25, 2008 Share Posted August 25, 2008 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); ?> Quote Link to comment Share on other sites More sharing options...
revraz Posted August 25, 2008 Share Posted August 25, 2008 You need to clarify your question. Quote Link to comment Share on other sites More sharing options...
saad|_d3vil Posted August 25, 2008 Author Share Posted August 25, 2008 see this site http://www.apnimuskaan.com/sadasdas.php there is a sql database table Quote Link to comment Share on other sites More sharing options...
joquius Posted August 25, 2008 Share Posted August 25, 2008 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. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 25, 2008 Share Posted August 25, 2008 I wish that I had any idea what you're asking. D: @joquius: The forum is buggy. It automatically changes </a> to [/url] when doing links. >_> Quote Link to comment Share on other sites More sharing options...
revraz Posted August 25, 2008 Share Posted August 25, 2008 You need to use CODE tags if you use HTML in your post. Quote Link to comment Share on other sites More sharing options...
saad|_d3vil Posted August 25, 2008 Author Share Posted August 25, 2008 php_b34t can you help me here here is my php code Quote Link to comment Share on other sites More sharing options...
revraz Posted August 25, 2008 Share Posted August 25, 2008 I don't think anyone knows what you are asking. Quote Link to comment Share on other sites More sharing options...
saad|_d3vil Posted August 25, 2008 Author Share Posted August 25, 2008 why is i am telling wroung ? php_b34t was trying to tell me but my last topic was locked Quote Link to comment Share on other sites More sharing options...
php_b34st Posted August 25, 2008 Share Posted August 25, 2008 I agree with revraz, as far as i can gather from the last post you are already using the get function like i suggested now all u need to do is use that variable to grab the data from the second table Quote Link to comment Share on other sites More sharing options...
saad|_d3vil Posted August 25, 2008 Author Share Posted August 25, 2008 what is variable Quote Link to comment Share on other sites More sharing options...
php_b34st Posted August 25, 2008 Share Posted August 25, 2008 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 Quote Link to comment Share on other sites More sharing options...
saad|_d3vil Posted August 25, 2008 Author Share Posted August 25, 2008 thank you very much thank you all Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.