SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot samohtwerdna's Avatar
    Join Date
    Jul 2007
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    reset or change query string onClick??

    I wasn't sure where to put this question, but since I am using php this is as good a place as any I think.

    Anyway, I have a home.php page which displays the most current news story entered by an admin etc. At the end of the short description of the news story there is a link to [more] i.e. the rest of the story which is on news.php

    Currently when you click on the link news.php only comes up with that story (which is the way I want it) There is a link/button on the top of the page to "View all" which I would like to set so that all the stories show. (also, you can navagate to news.php from the main nav and I would like to show all stories as the default when ever anyone comes to the page from that link.

    I am simply limiting my query of the db like:
    Code:
    $query_rsNews = "SELECT * FROM news WHERE Type = 'N' AND FlagStatus != 'I' ORDER BY DisplayOrder DESC LIMIT 1";
    $rsNews = mysql_query($query_rsNews, $connection1) or die(mysql_error());
    $row_rsNews = mysql_fetch_assoc($rsNews);
    $totalRows_rsNews = mysql_num_rows($rsNews);
    Is it possible to make an onClick event that can add/subtract the "LIMIT 1"??

    or is there a better way to do this??

    Thanks for any help,

  2. #2
    SitePoint Enthusiast traxxas's Avatar
    Join Date
    Jan 2007
    Location
    San Diego, CA
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you serving the different content on the same URL? The selection for showing all stories or just one story should be selected from the URL or the URL query string.

    eg
    /news.php?article=1 [for article 1]
    /news.php [for all stories]

  3. #3
    SitePoint Zealot samohtwerdna's Avatar
    Join Date
    Jul 2007
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have this function:

    Code:
    <script language="javascript" type="text/javascript">
    function showMore('bob') {
    	// show table if hidden or hide table if shown
    	if (document.getElementById('bob').style.display == '')
    		document.getElementById('bob').style.display = 'none';
    	else
    		document.getElementById('bob').style.display = '';
    }
    </script>
    but I can't get my div "bob" to hide once it repeats. ?

    I do have a url showing news.php?NewsId=7
    but that still shows all the news stories??

    I assume that I need to set something in my do while loop concerning the NewsId?

  4. #4
    SitePoint Zealot samohtwerdna's Avatar
    Join Date
    Jul 2007
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops,

    I forgot to add the "WHERE NewsId = '$_GET[NewsId]'" in my query
    silly me - all is working now.

    Thanks for the help.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jan 2003
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by samohtwerdna View Post
    Oops,

    I forgot to add the "WHERE NewsId = '$_GET[NewsId]'" in my query
    silly me - all is working now.

    Thanks for the help.
    It is a VERY VERY bad idea to construct SQL queries using unfiltered data taken directly from the query string.

    See: http://shiflett.org/articles/sql-injection


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •