Jump to content

tommr

Members
  • Posts

    43
  • Joined

  • Last visited

Everything posted by tommr

  1. I am sorry that I can not explain this in a fashion that anyone can understand. Forget about the "search by date". When users enter a date they must use the calendar I provide in the submit form so that the date is input in the proper fashion. That is not the problem. If you search by anything the date will be in the results as well as show name, address and so on. The problem is the script will print the date as 2010 17 12 and so on. The code I submitted will change the date from 2010 17 12 to Dec 17 2010 when I use the solution to fix the date it interferes with all the search so if you search for watertown in city it returns all the results in the table instead of only the watertown results. If I take the date fix code out the search will return the proper results, by city or state, but the date is displayed as 2010 17 12 which is too confusing for users to understand. I was hoping that someone might spot a coding error or conflict that was causing the search to return all results instead of the state or city.
  2. I am sorry if I was vague. I was hoping there was a obvious error in my script that would be obvious to someone who knows more about PHP than I do. This script searches for info and displays it in a fashion that includes city, state, show name, date etc. There is a test version at http://www.artsandcraftsnetwork.com/shows if you search for ny in state or watertown in city you will get the same results. I want to break the date down so people can understand it instead of the date format that is stored in the database. This code breaks the date down but something in the code below is conflicting with the search function of the script. Here is the part code that changes the date display. If I remove this from the code the search works fine but the date is messed up. $sql = "SELECT *, DATE_FORMAT(`start_date`, '%b %e, %Y') AS s_date FROM craft_shows"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) The problem I am having is this code interferes with the search function of the script and no matter which search term is selected , state, city or date, all the results are returned. Here is the form that goes with the script. <form name="search" method="get" action="<?php $PHP_SELF?>"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="venue_state">state</option> <Option VALUE="venue_city">city</option> <Option VALUE="start_date">date</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" value="Search" /> </form>
  3. This script breaks the date down fine, the trouble is it interferes with the search function. I was hoping that someone could spot the conflicting code. Not to mention that a large percentage of what I have found posted on the internet is incorrect in one way or another.
  4. I am trying to get this script to display the date like Dec 17, 2010 and have the search function work too. If I try to change the date the search malfunctions and if I take the date function away the date is 2010 12 17 I thought we had this nailed down the other day but in my excitement I neglected to test the city search. Here is the script. <?php $find = trim($_GET['find']); $field = $_GET['field']; if($find && $field) { // we have search form submitted // check for values to prevent sql injection $valid_fields = array("venue_state", "venue_city", "start_date"); if(!in_array($field, $valid_fields)) die("Error: Invalid field!"); //connect mysql_connect("localhost", "arts_cshow", "TrPh123Yuo") or die(mysql_error()); mysql_select_db("arts_shows") or die(mysql_error()); echo "<h2>Search Results for $find in $field</h2>\n"; $find = addslashes($find); $result = mysql_query("SELECT * FROM craft_shows WHERE $field LIKE '%$find%'"); if(mysql_num_rows($result) == 0) { echo "<p>0 matches found.</p>"; } else { echo "<table><tr><td class=\"shows\">"; $sql = "SELECT *, DATE_FORMAT(`start_date`, '%b %e, %Y') AS s_date FROM craft_shows"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { echo "<a href='/show_submits/show_detail.php?id={$row['id']}'>Details</a>\n"; echo $row['venue_state'] . " {$row['s_date']} {$row['show_name']} {$row['venue_city']}<br>\n"; } echo "</td></tr></table>\n"; } } ?> thanks
  5. I can figure this out. I thought it was working but for what ever reason this code calls all the results no matter I select from the drop down menu. If I take the date and code fix out it works on but the date is not displayed as I want. I have tried 6 ways to Sunday and no dice. <?php $find = trim($_GET['find']); $field = $_GET['field']; if($find && $field) { // we have search form submitted // first of all we need to check for values to prevent sql injection $valid_fields = array("venue_state", "venue_city", "start_date"); if(!in_array($field, $valid_fields)) die("Error: Invalid field!"); // connect to our Database mysql_connect("localhost", "arts_cshow", "My Password") or die(mysql_error()); mysql_select_db("arts_shows") or die(mysql_error()); echo "<h6>Search Results for $find </h6>\n"; $find = addslashes($find); $result = mysql_query("SELECT * FROM craft_shows WHERE $field LIKE '%$find%'"); if(mysql_num_rows($result) == 0) { echo "<p>0 matches found.</p>"; } else { $id = $row['id']; echo "<table class=\"stshows\"><tr><td class=\"stshows\">"; while($row = mysql_fetch_array($result)) $sql = "SELECT *, DATE_FORMAT(`start_date`, '%b %e, %Y') AS s_date FROM craft_shows"; $result = mysql_query($sql); while( $row = mysql_fetch_assoc($result) ) { echo "<a href='/show_submits/show_detail.php?id={$row['id']}'>Details</a>\n"; echo $row['venue_state'] . " {$row['s_date']} {$row['show_name']} {$row['venue_city']}<br>\n"; } echo "</td></tr></table>\n"; } } ?>
  6. Thank you thank you. It works but by the looks of the results I need to sort by date! One of the problem of working from a book is that if I have questions there is no one to help. Thanks to your help I now understand the concept of FROM. This is a big help in getting that detail nailed down but I really appreciate your taking the time to show what I am doing wrong. I think I will spend some time browsing the forum for more ideas of how to make the site work better.
  7. No errors but nothing is printing for date. I am using... $sql = "select * from craft_shows DATE_FORMAT(`start_date`, '%b %e, %Y') AS s_date "; echo "<a href='/show_submits/show_detail.php?id={$row['id']}'>Details</a>\n"; echo $row['venue_state'] . " {$row['s_date']} {$row['show_name']} {$row['venue_city']}<br>\n";
  8. The date is stored as 2010-12-10 I want to display the date as Dec 10, 2010 I used the strftime('%b %d, %Y', strtotime($row['start_date'])) on other parts of the site and it worked with out noticeable trouble. Here is an example... http://www.artsandcraftsnetwork.com/show_submits/6ny.php Now if I go to http://www.artsandcraftsnetwork.com/shows/ and search for ny I get the list but with the 2010-12-10 The database version is too confusing. The whole blasted thing is a Frankenstein of parts and pieces I bought, wrote and had other help with. I tried to find an events script that would do what I wanted but none was available and I do not have the funds to commission one so there you go. Any help would be appreciated.
  9. Is this correct then? strftime('%b %d, %Y', strtotime($row['start_date'])) I am having nothing but trouble with this.
  10. Thanks again for the quick reply. That helps make it clear. I am still having trouble with the date but I will endeavor to persevere.
  11. Can you be a little more specific? When I use the first instance it works fine. I just want to change the format of the date. I am new to this and am trying to learn.
  12. I use strftime('%b %d, %Y', strtotime($row['start_date'])); in several places and it works fine. When I take this code { echo "<a href=\"/show_submits/show_detail.php?id=" $row['id'] "\">Details</a>\n"; echo $row['venue_state'] " " $row['start_date'] " " $row['show_name'] " " $row['venue_city'] "<br>\n"; } and change it to this code { echo "<a href=\"/show_submits/show_detail.php?id=" $row['id'] "\">Details</a>\n"; echo $row['venue_state'] " " strftime('%b %d, %Y', strtotime($row['start_date'])); " " $row['show_name'] " " $row['venue_city'] "<br>\n"; } I get this error. Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/arts/public_html/shows/index.html on line 194 The only change I made was for the $row['show_name'] Am I making an obvious mistake?
  13. Ok, maybe this is a better way to ask this question. Below is the script that displays the information from my database. This is just a basic information display and the form button on each line leads to the page for the detailed results, map, weather etc. Is it possible to use some kind of pagination with this table and form? I am really new to this and would appropriate any help. Thanks. <?php include('../show_submits/includes/config.db.php'); if ($link) { $sql = "select * from craft_shows WHERE venue_state='NY'"; $result = mysql_query($sql) or die(mysql_error()); echo "<table class='table7' width='100%' cellpadding='5' cellspacing='1'>"; echo "<tr><td> </td><td>Show</td><td>Address</td><td>City</td><td>State</td><td>Date</td><td>Attendance</td></tr>"; echo "<tr><td colspan='7'><hr></td></tr>"; while($row = mysql_fetch_array($result)){ $id = $row['id']; echo "<tr><td>"; echo "<form name='show_details' method='post' action='../show_submits/show_detail.php' onsubmit='return submitForms(this);'/>"; echo "<input type='hidden' name='id' value='$id' />"; echo "<input type='submit' name='submit' value='Details' /> "; echo "</form>"; echo "</td><td>"; echo $row['show_name']; echo "</td><td>"; echo $row['venue_address']; echo "</td><td>"; echo $row['venue_city']; echo "</td><td>"; echo $row['venue_state']; echo "</td><td>"; echo $row['start_date']; echo "</td><td>"; echo $row['num_visitors']; echo "</td></tr>"; } echo "</table>"; } ?>
  14. I am trying to use after market pagination and was hoping someone could tell me what I am doing wrong or better yet what to do right. Here is the page I am testing. http://www.artsandcraftsnetwork.com/show_submits/2ny.php Here is my original script. It works well but the page will get really long when the database fills up. <?php include('../show_submits/includes/config.db.php'); if ($link) { $sql = "select * from craft_shows WHERE venue_state='NY'"; $result = mysql_query($sql) or die(mysql_error()); echo "<table class='table7' width='100%' cellpadding='5' cellspacing='1'>"; echo "<tr><td> </td><td>Show</td><td>Address</td><td>City</td><td>State</td><td>Date</td><td>Time</td></tr>"; echo "<tr><td colspan='7'><hr></td></tr>"; while($row = mysql_fetch_array($result)){ $id = $row['id']; echo "<tr><td>"; echo "<form name='show_details' method='post' action='../show_submits/show_detail.php' onsubmit='return submitForms(this);'/>"; echo "<input type='hidden' name='id' value='$id' />"; echo "<input type='submit' name='submit' value='Details' /> "; echo "</form>"; echo "</td><td>"; echo $row['show_name']; echo "</td><td>"; echo $row['venue_address']; echo "</td><td>"; echo $row['venue_city']; echo "</td><td>"; echo $row['venue_state']; echo "</td><td>"; if ($row['start_date'] == $row['start_date']) { echo $row['start_date']; } else { echo $row['start_date']; echo "-"; echo $row['end_date']; } echo "</td><td>"; echo $row['start_time']; echo $row['start_ampm']; echo "-"; echo $row['end_time']; echo $row['end_ampm']; echo "</td></tr>"; } echo "</table>"; } ?> //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Here is the first part of the pagination script. // I have this on the page right under my script just as it is here. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <?php include('../show_submits/includes/config.db.php'); $rpp = 10; // results per page $adjacents = 4; $page = intval($_GET["page"]); if(!$page) $page = 1; $reload = $_SERVER['PHP_SELF']; // count total number of appropriate listings: $tcount = mysql_num_rows($result); // count number of pages: $tpages = ($tcount) ? ceil($tcount/$rpp) : 1; // total pages, last page number $count = 0; $i = ($page-1)*$rpp; while(($count<$rpp) && ($i<$tcount)) { mysql_data_seek($result,$i); $query = mysql_fetch_array($result); // output each row: echo "<p>" . $query['table_field_1'] . ", " . $query['table_field_2'] . "</p>\n"; $i++; $count++; } ?> //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // And the part that calls the actual pagination script with the formatting. // Again I have this right under the last part as it appears here with out the comments. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <?php include("pagination1.php"); echo paginate_one($reload, $page, $tpages); ?> // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // And the script with the formatting. // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <?php /************************************************************************* php easy :: pagination scripts set - Version One ========================================================================== Author: php easy code, www.phpeasycode.com Web Site: http://www.phpeasycode.com Contact: webmaster@phpeasycode.com *************************************************************************/ function paginate_one($reload, $page, $tpages) { $firstlabel = "First"; $prevlabel = "Prev"; $nextlabel = "Next"; $lastlabel = "Last"; $out = "<div class=\"pagin\">\n"; // first if($page>1) { $out.= "<a href=\"" . $reload . "\">" . $firstlabel . "</a>\n"; } else { $out.= "<span>" . $firstlabel . "</span>\n"; } // previous if($page==1) { $out.= "<span>" . $prevlabel . "</span>\n"; } elseif($page==2) { $out.= "<a href=\"" . $reload . "\">" . $prevlabel . "</a>\n"; } else { $out.= "<a href=\"" . $reload . "&page=" . ($page-1) . "\">" . $prevlabel . "</a>\n"; } // current $out.= "<span class=\"current\">Page " . $page . " of " . $tpages . "</span>\n"; // next if($page<$tpages) { $out.= "<a href=\"" . $reload . "&page=" .($page+1) . "\">" . $nextlabel . "</a>\n"; } else { $out.= "<span>" . $nextlabel . "</span>\n"; } // last if($page<$tpages) { $out.= "<a href=\"" . $reload . "&page=" . $tpages . "\">" . $lastlabel . "</a>\n"; } else { $out.= "<span>" . $lastlabel . "</span>\n"; } $out.= "</div>"; return $out; } ?>
×
×
  • 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.