Jump to content

Help Required! How To Open Each Record Using Php


niccki

Recommended Posts

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?>&current=0&text=<?=$_REQUEST['text']?>&field=<?=$_REQUEST['field']?>&sortby=<?=$_REQUEST['sortby']?>">|< First</a>
          <?php if ($current >= 10) { ?>
          <a href="<?=$_SERVER['PHP_SELF']?>?max=<?=$max?>&current=<?=($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?>&current=<?=($current+10)?>&text=<?=$_REQUEST['text']?>&field=<?=$_REQUEST['field']?>&sortby=<?=$_REQUEST['sortby']?>">Next >></a>
          <?php } else { ?>
          Next >>
          <?php } ?>
          <a href="<?=$_SERVER['PHP_SELF']?>?max=<?=$max?>&current=<?=(floor($max/10)*10)?>&text=<?=$_REQUEST['text']?>&field=<?=$_REQUEST['field']?>&sortby=<?=$_REQUEST['sortby']?>">Last >|</a>

      <? }
   ?>

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

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