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); ?> Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/ Share on other sites More sharing options...
revraz Posted August 25, 2008 Share Posted August 25, 2008 You need to clarify your question. Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/#findComment-625014 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 Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/#findComment-625018 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. Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/#findComment-625019 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. >_> Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/#findComment-625020 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. Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/#findComment-625120 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 Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/#findComment-625155 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. Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/#findComment-625157 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 Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/#findComment-625160 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 Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/#findComment-625161 Share on other sites More sharing options...
saad|_d3vil Posted August 25, 2008 Author Share Posted August 25, 2008 what is variable Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/#findComment-625163 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 Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/#findComment-625166 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 Link to comment https://forums.phpfreaks.com/topic/121241-solved-how-i-inserted-table/#findComment-625168 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.