niccki Posted April 29, 2009 Share Posted April 29, 2009 Hi, can anyone help me with my coding please.. I am developing simple website for my personal use. I have written this code which works perfectly well. Problem is that i cannot click on each record (newstitle in this case) which appears on my webpage to open its full description. How do i write codes to open each record information by clicking its name (newstitle). I hope i make sense and someone can help me.. If you need further help than please post your email add i can provide you with screenshots which will make more sense. Please see the atttached file to view my webpage. <?php function func_news_result() { ?> <?php require "connect.php"; require "functionNews.php"; $query="select * from news"; $result = @mysql_query($query,$connection) or die ("Unable to perform query.<br/>$query<br/>".mysql_error()); ?> <p>Click on Name</p> <br /><a href="addNews_page.php">Add latest News</a></td> </tr> <table border="1"> <tr> <th width="250">News Title</a></th> <th width="340">Description</th> <th width="90">Date</th> <th width="50">Edit</th> <th width="50">Delete</th> </tr> <?php while($row=mysql_fetch_array($result)) { ?> <tr> <td><a href="newsDPage.php"><?=$row['newstitle']?></a><p><?=$row['author']?></p></td> <td><?=$row['description']?></td> <td><?=$row['date']?></td> <td><a href="editNews_page.php?newsid=<?=$row['newsid']?>" onClick="return confirm('Do you really want to edit this?');">Edit</a></td> <td><a href="deleteNews.php?newsid=<?=$row['newsid']?>" onClick="return confirm('Do you really want to delete this?');">Delete</a></td> </tr> <?php } ?> </table> <a href="<?=$_SERVER['PHP_SELF']?>?max=<?=$max?>¤t=0&text=<?=$_REQUEST['text']?>&field=<?=$_REQUEST['field']?>&sortby=<?=$_REQUEST['sortby']?>">|< First</a> <?php if ($current >= 10) { ?> <a href="<?=$_SERVER['PHP_SELF']?>?max=<?=$max?>¤t=<?=($current-10)?>&text=<?=$_REQUEST['text']?>&field=<?=$_REQUEST['field']?>&sortby=<?=$_REQUEST['sortby']?>"><< Previous</a> <?php } else { ?> << Previous <?php } ?> <?php if (($current + 10) < $max) { ?> <a href="<?=$_SERVER['PHP_SELF']?>?max=<?=$max?>¤t=<?=($current+10)?>&text=<?=$_REQUEST['text']?>&field=<?=$_REQUEST['field']?>&sortby=<?=$_REQUEST['sortby']?>">Next >></a> <?php } else { ?> Next >> <?php } ?> <a href="<?=$_SERVER['PHP_SELF']?>?max=<?=$max?>¤t=<?=(floor($max/10)*10)?>&text=<?=$_REQUEST['text']?>&field=<?=$_REQUEST['field']?>&sortby=<?=$_REQUEST['sortby']?>">Last >|</a> <? } ?> [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/156088-help-required-how-to-open-each-record-using-php/ Share on other sites More sharing options...
ignace Posted April 29, 2009 Share Posted April 29, 2009 You can do this in 2 ways the first would be using javascript and is probably the most recommended and the second way is by using php. The first way would be like this: <script type="text/javascript"> function showMore(id) { var el = document.getElementById(id); if (el.style.display == 'none') { el.style.display = 'block'; } else { el.style.display = 'none'; } } </script> <h1 onclick="showMore('a-unique-name')">Some Title</h1> <p style="display: none" id="a-unique-name">some text</p> The second would be like this: <?php $titleId = 0; if (isset($_GET['title_id'])) { $titleId = $_GET['title_id']; } ..query.. while ($title = mysql_fetch_assoc($queryResult)) { ..title.. if ($title['id'] === $titleId) { ..show description.. } } ?> although for accessibility reasons we should re-commend a mix of both Link to comment https://forums.phpfreaks.com/topic/156088-help-required-how-to-open-each-record-using-php/#findComment-821684 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.