saad|_d3vil Posted August 28, 2008 Share Posted August 28, 2008 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 More sharing options...
DarkWater Posted August 28, 2008 Share Posted August 28, 2008 Use a WHERE clause for the id? Link to comment https://forums.phpfreaks.com/topic/121726-solved-how-i-make-page-for-each-id/#findComment-627936 Share on other sites More sharing options...
PHPTOM Posted August 28, 2008 Share Posted August 28, 2008 <?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); Link to comment https://forums.phpfreaks.com/topic/121726-solved-how-i-make-page-for-each-id/#findComment-627941 Share on other sites More sharing options...
saad|_d3vil Posted August 28, 2008 Author Share Posted August 28, 2008 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); ?> Link to comment https://forums.phpfreaks.com/topic/121726-solved-how-i-make-page-for-each-id/#findComment-627951 Share on other sites More sharing options...
saad|_d3vil Posted August 28, 2008 Author Share Posted August 28, 2008 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); Link to comment https://forums.phpfreaks.com/topic/121726-solved-how-i-make-page-for-each-id/#findComment-627957 Share on other sites More sharing options...
PHPTOM Posted August 28, 2008 Share Posted August 28, 2008 <?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); ?> Link to comment https://forums.phpfreaks.com/topic/121726-solved-how-i-make-page-for-each-id/#findComment-627960 Share on other sites More sharing options...
saad|_d3vil Posted August 28, 2008 Author Share Posted August 28, 2008 thank you very much thank you Link to comment https://forums.phpfreaks.com/topic/121726-solved-how-i-make-page-for-each-id/#findComment-627964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.