SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: Freddy...

Hybrid View

  1. #1
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am looking for the post you made about breaking up results into multiple pages...I found this one but I don't remember it as being the one I wanted. Was there another?

    http://www.sitepointforums.com/showt...threadid=10959

    I am also looking for the thread where you showed me how to create an array from a SELECT query

    cheers
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah that is the one I did for page navigation did you need to work differently?

    And the one about the array from select statement I think is this one:
    http://www.sitepointforums.com/showt...threadid=10846
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh...I got the random verses working fine...take a look if you want http://www.oursmallgroup.com

    Well...let me explain real quick what I am trying to accomplish. Check out the above URL, then go to prayer requests. Look at the header where the date is, then look at the requests themselves. Currently I am running two queries to the DB. One to get the date and one to get the requests.

    This is the query to get the date:
    SELECT date FROM osg_prayer_request GROUP BY date

    This is the query to get the requests:
    SELECT pid,uid, main_text FROM osg_prayer_request

    This setup worked fine when I only had requests from one date. Now that I have requests from different dates, the query for the date prints out every date that is in the DB. The same thing for the requests. What I want to do is this:
    [*] Print the most recent date and prayer requests. The requests could get input almost every day so I would like to group the requests by week. example: everyting from 10-6 to 10-12 would show up on one page.
    [*] Print a dropdown menu with the dates pulled from the database, once selected, the user would get a page just like above for the dates selected.

    Here is the code I am using to print the requests dropdown menu.

    Code:
    <form action="<?php echo("$php_self"); ?>" method="post" name="pr_select">
    <select name="select_date" onChange="jumpMenu('parent',this,0)" style="font-size: 9;">
      <option value="2000-11-02" selected>Past Prayer Requests</option>
    <?php
    
    $conn = mysql_connect($dbhost, $dbuser, $dbpass);
    if (!$conn) {
    echo "<P>Unable to connect to the database server at this time.</P>";
    exit();
    }
    
    if (! @mysql_select_db($dbname) ) {
    echo( "<P>Unable to locate the database at this time.</P>" );
    exit();	  
    }
    
    $result = mysql_query("SELECT date from osg_prayer_request GROUP BY date desc;");
    if (!$result) {
    echo "<P>Error performing query on database";
    exit();		  
    }
    
    while ($row = mysql_fetch_array($result)) {
    echo "<option value=\"".$row["date"]."\">Week of ".$row["date"]."</option>\n";  
    }
    
    ?>
    </select></td></tr></form>
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let me see if I understand correctly. You have a table called osg_prayer_request. You want to get the most recent date from the table and display it at the top of the screen with the prayers from that date below it. then you want to have a dropdown list with the previous weeks dates in it and if someone choose a date from dropdown it will redisplay the page and show the prayers for that week?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that sounds like it...I REALLY want to be able to do this myself...but I need to be humble I admit that I can't program well.

    Oh man...I just thought of something. In my original modeI was only planning on Prayer requests being updated once a week. Thus the date at the top. Now I am going to let people come to the site and input a request whenever they want to. That means I could have one prayer request every day or 10, or none.

    What would be the best way to deal with that? I want to display the date that request was listed, but I don't want just one request per page.

    How about this. Print the date at the top as "The Week of" in that blue header. Then print the actual date of the request directly underneath the request itself...or beside it. I could do that part...I have also already done the drop down part. I just need to figure out how to

    a) limit the results to just ane period of time
    b) only get requests for that period.

    Does that sum it up?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    UNderstood, about you wanting to do this yourself, so let me just push you in the right direction. So you date field has something like this 11-02-00 for the date? well then I would start by checking whether they have come to the page for the first time or if they have selected a date from the drop down. If it is the first time I would use the date() function to create today's date in a similar format as what is stored in the date field, then I would create another date using mktime() that is one week forward in time. then I would make query something like

    "SELECT fields from table WHERE (datefield > '$todaysdate') AND (datefield < '$weekfromtoday')"


    So now give that a try and if you need to see code just let me know.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "SELECT fields from table WHERE (datefield > '$todaysdate') AND (datefield < '$weekfromtoday')"
    Would this give me everything in between the dates?

    I want a header that says "Week of X " and prayer requests that have been posted inside that period of time.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  8. #8
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes as long as you date field contains the dates in the format of 11-02-00 But now it sounds like you need to get the beginning of the week for a particular date and then get the end of the week as well so if someone went to the site today it would say Week of: Oct 31
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  9. #9
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok...well I think I can at least start working on this. I can yell for help if I need it. One thing...I am using the date property on the date field, meaning htat I have to enter it like 2000-11-03 or it will be invalid.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  10. #10
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay well you get the date into that format with DATE("Y-m-d");
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •