PHP - Moved: Advanced Php Tutorial
This topic has been moved to Miscellaneous.
http://www.phpfreaks.com/forums/index.php?topic=343600.0 Similar TutorialsHey guys, I'm looking for some sort of tutorial on how to code a search script which would allow users to select number of results per page (and take care of the page 1, page 2, etc. links accordingly) as well as order them by date, most views, etc. I thought I'd be good to do this on my own but my script is looking very dirty and I'm pretty sure it isn't very secure.. anyone ever consult a tutorial with main guidance as how to code the kind of script I'm interested in?? thanks This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=308352.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=351363.0 This topic has been moved to Linux. http://www.phpfreaks.com/forums/index.php?topic=334310.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=130332.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=330907.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=358297.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=343169.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=334229.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=332907.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348851.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=316360.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=351535.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=321530.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=342211.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=347977.0 Hey guys, at the moment I am trying to do an advanced search on events, 4 fields - county, date, title and hoster, so I am not really sure how to go about this but either way I started writing a script to do this, you learn from trying and mistaken right? Now I made sure the radio buttons all worked before I tryed this, checking the values of them on the form (seperate page) and if they get transferred correctly over to this page, basically for every field there are 2 radio boxes yes and No, which means for them to be included in the search or not, this is the code I have so far and if no radio buttons are selected and the fields are empty it comes up with the table and no results, when everything is set to no the page is blank, when everything is set to yes and I put the correct information in the fields then it comes up with the right data, so far it basically only works if all is yes (I will change it to LIKE later so they don't have to put in the exact information for certain fields) so I guess I am on the right way? Where and what am I doing wrong? Code: [Select] <?php session_start(); include 'connect.php'; $username = $_SESSION['username']; if(!isset($_SESSION['username'])) { echo '<div align="center">'; echo 'You have to be a registered member to be able to view events.<br><br> <a href="register.html">Click here to register</a>'; echo '<br><br><br><br>Or if you are already a member, please login to use this area.<br>'; echo ' <form method="POST" action="loginverification.php"> <table border="0"> <tr><td> Username: </td><td><input type="text" name="username" size="15" /></td></tr> <tr><td>Password:</td><td> <input type="password" name="password" size="15" /></td></tr> </table> <div align="center"> <p><input type="submit" value="Login" /></p> </div> </form>'; echo '</div>'; } else{ $theDate = isset($_REQUEST["date1"]) ? $_REQUEST["date1"] : ""; $eventcounty = $_POST['county']; $eventdescriptionheader = $_POST['eventdescriptionheader']; $hoster = $_POST['hoster']; if($_POST['searchcounty'] == "No") { $result = mysql_query("SELECT * FROM Events WHERE eventdate = '$theDate' AND eventdescriptionheader = '$eventdescriptionheader' AND hoster = '$hoster' ORDER BY eventdate ASC")or die(mysql_error()); } elseif($_POST['searchdate'] == "No") { $result = mysql_query("SELECT * FROM Events WHERE eventcounty = '$eventcounty' AND eventdescriptionheader = '$eventdescriptionheader' AND hoster = '$hoster' ORDER BY eventdate ASC")or die(mysql_error()); } elseif($_POST['searchtitle'] == "No") { $result = mysql_query("SELECT * FROM Events WHERE eventcounty = '$eventcounty' AND eventdate = '$theDate' AND hoster = '$hoster' ORDER BY eventdate ASC")or die(mysql_error()); } elseif($_POST['searchhoster'] == "No") { $result = mysql_query("SELECT * FROM Events WHERE eventcounty = '$eventcounty' AND eventdate = '$theDate' AND eventdescriptionheader = '$eventdescriptionheader' ORDER BY eventdate ASC")or die(mysql_error()); } else { $result = mysql_query("SELECT * FROM Events WHERE eventcounty = '$eventcounty' AND eventdate = '$theDate' AND hoster = '$hoster' AND eventdescriptionheader = '$eventdescriptionheader' ORDER BY eventdate ASC")or die(mysql_error()); echo '<br>'; echo "<table border='0'> <tr> <th>Date/Time</th> <th>Event</th> <th>Participants</th> <th>Hoster</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>"; print date('d M Y', strtotime($row['eventdate'])); echo " "; echo $row['starttime'] . "</td>"; echo '<td><a href="showevent.php?eventsID='; echo $row['eventsID']; echo '">'; echo $row['eventdescriptionheader']; echo "</a></td>"; echo "<td>" . $row['currentparticipants'] . "/" . $row['maxparticipants'] . "</td>"; echo "<td>" . $row['hoster'] . "</td>"; echo "</tr>"; } echo '</table>'; $check = mysql_num_rows($result); if ($theDate == "0000-00-00") { echo 'You did not select a date.'; echo '<INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;">'; } elseif ($check == 0) { echo 'No results found.'; echo '<INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;">'; } echo '<br><INPUT TYPE="button" VALUE="Back" onClick="history.go(-1);return true;"> '; } } ?> Good morning, I'm creating a content management system for my game. It's RPG style, so it contains many tasks, however, adding them is a bit complicated process and the system isn't simple. Therefore, simple web form is needed, but there are fields that depend on others. For instance, if quest type is k (which means killing task), a field asking how many different kinds of monsters need to be killed, then there should appear x fields with more specific information. To sum up, i need an example, advice or sth that would help me to create this type of html where new fields appear automatically depending on the chosen ones. Thanks in advance, Karolis Im building an advanced search feature and its mostly going fine. The only problem is that results are displayed more times than they need to be. I have a test post in the database: p_name p_content Testing Advanced Search This is to test the advanced search When i do a search with the keywords "testing advanced search" and set it to match any keywords it does bring up this post as it should do. But it is displaying it 3 times when there is only one instance of it in the database. here is my code: $match = $_POST['match']; // for this example match === any $keywords = $_POST['keywords']; // for this example keywords === testing advanced search $within = $_POST['within']; // for this example within === p_c (post_content only) switch($within) { case 'p_s_c': default: $sql_match = 'p.p_name, p.p_content'; break; case 'p_c': $sql_match = 'p.p_content'; break; case 'p_s': $sql_match = 'p.p_name'; break; case 't_t': $sql_match = 't.t_name'; break; } $match === 'all' ? $keywords = '"'.$keywords.'"' : $keywords = $keywords; $query = $link->query("SELECT p.*, t.* FROM ".TBL_PREFIX."posts as p JOIN ".TBL_PREFIX."topics as t WHERE MATCH ($sql_match) AGAINST('$keywords' IN BOOLEAN MODE)") or die(print_link_error()); while($row = $query->fetch(PDO::FETCH_ASSOC)) { $return = preg_split('|, |', $sql_match); for($i=0; $i<count($return); $i++) { $return[$i] = substr($return[$i], 2); echo '<p>Results: '.$row[$return[$i]].'</p>'; } } And here is the echoed query: SELECT p.*, t.* FROM asf_posts as p JOIN asf_topics as t WHERE MATCH (p.p_content) AGAINST('Testing advanced search' IN BOOLEAN MODE) Any help? ok here is my problem... for example: i have 1000 files with 15 entrys each. but in the last one there is only 8 entrys. (i want to make a pagination) i want to display 15 entrys on each page. also how to calculate from which entry to which should it read. (i have another text file in which is the number of total entrys in all files together) for the first page it should read the first 8 and from thefirst file and the first 7 from the second file to get 15 displayed on the page. i was tryin now for some hours, but i just can't figure it out. :S and i know that i will think how stupid i'm after i will see how it should be done. :S |