Jump to content

jamesbrauman

Members
  • Posts

    42
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jamesbrauman's Achievements

Member

Member (2/5)

0

Reputation

  1. I have been trying to figure out how to do this but as of yet I haven't thought of a way. I have a mysql database containing four tables that I want to search. On the search page, there is a textbox for the query string, and four checkboxes - each of them relate to each table and whether or not to search that table. The HTML looks like this: <form action="search_process.php" method="post"> <p> Search Query: <input name="q" type="text" class="text" /><br /> <input type="checkbox" name="search_jokes" checked="checked" /> Search Jokes <input type="checkbox" class="checksecond" name="search_pictures" checked="checked" /> Search Pictures<br /> <input type="checkbox" name="search_movies" checked="checked" /> Search Movies <input type="checkbox" class="checksecond" name="search_games" checked="checked" /> Search Games<br /><br /> <input type="submit" class="button" value="Search" /> </p> </form> So basically, you can either search nothing, or everything, or a combination of those. I am receiving the variables okay, but do not know what is the best way to go about retrieving the results from the database. The four tables along with the fields I want to search look like this: jokedata - title, joke picturedata - picturetitle moviedata - title, description gamedata - title I want the search string to broken into an array using space as the delimiter and it should search all of these words. I know how to do this: $search_array = explode(" ", $_POST['q']); But I don't know how I would go about using that exploded data in generated mysql LIKE's, searching all the fields I wrote about. But it would be generated as something like this I am guessing: ... WHERE joketitle LIKE "%searchterm1%" OR joketitle LIKE "%searchterm2%" OR joke LIKE "%searchterm1%" OR joke LIKE "%searchterm2%" But that code doesn't just need to be for jokes, it needs to be for all the tables that needs to be searched, and using the fields I wrote above. Once I have received my data I need a way to tell which table each row came from - jokedata, picturedata, moviedata or gamedata. The reason for this is that each row should have the id of the item, and on the search page I need to write a link like "viewjoke.php?id=$id" OR "viewpic.php?id=$id". Also I would like paginated search results, but this is not necessary and I could probably research as to how to do this. I am not asking for the complete code but I would like someone to point out a logical and efficient way to do this so I may try to write the code, and perhaps write up some numbered steps. Thanks a million, I am awaiting your answers
  2. Don't worry - I found http://www.oscaralexander.com/tutorials/how-to-make-sexy-buttons-with-css.html
  3. Set it as fixed, the use an IE conditional statement to revert back to what was working in IE.
  4. Hello, I have spent the last three hours pulling my hair out over this, I cant seem to get it to work. I'm basically copying the pagination from this site: http://www.pixel2life.com. I liked the rounded corners and thought I would attempt it. This is a screenshot of what I am trying to acheive: I do not want to set a fixed width for these buttons, I want the text inside them to define how long they will be (the "512" button is longer than the "1" button). I decided that it was logical to break that image up into 6 parts, with three for each button - the left rounded side, the right rounded side, and a 1px slice of the background which can be repeated horizontally. And I thought the HTML markup would be something like this (note that I want the buttons displayed inline, and that "onpage" refers to the green button and "offpage" refers to the grey button): <span class="offpage"><span class="left"></span><span class="main">PAGENUMBERHERE</span><span class="right"></span> <span class="onpage"><span class="left"></span><span class="main">PAGENUMBERHERE</span><span class="right"></span> I can't seem to get it to WORK though. Please help me, I am in dire need! ??? Thanks.
  5. Don't worry, figured it out. (.*) wasn't matching newline characters.
  6. Lol I'm trying to extract the data between "Page:" and "Next Page" from a web page... no idea why this isn't working, but it isn't. Page source looks like this: <p >Page: <div style='width:300px;'><div id=page-no><a href='/cat.php?cat_id=46&begin=0&num=1&numBegin=1'></a><font color='#ff3366'><b>1</b></font><a></a> </div><div style='float:left; clear:left;'><a href='/cat.php?cat_id=46&numBegin=1&num=2&begin=14'> Next Page >> </a></div></div> ...And my regex code looks like this: $pattern = "/^Page:(.*)Next Page$/"; preg_match($pattern, $buffer, $matches); var_dump($matches); It's not matching though
  7. I'm looking for some way to display all the available avatars to a user when they are registering, and letting them to be able to select one. I have about 300 50x50 avatars and I would like to show them in a box about 200px high and 800px wide. How can I do this (which avatar the user selected also needs to be posted to my php application)?
  8. $searchResult = mysql_query("SELECT * FROM members WHERE LicState LIKE '%$SEARCH%' OR LicState2 LIKE '%$SEARCH%' OR LicState3 LIKE '%$SEARCH%' OR LicState4 LIKE '%$SEARCH%' ");
  9. I'll admit I'm not that experienced when it comes to user authentication. However I have tried to write some secure functions for user authentication for my website. Could you please take a look at these, and suggest any improvements or point out any flaws/errors? I want to make sure these are perfect before trying to implement them. #user authentication functions function clean_string( $value ) { if ( get_magic_quotes_gpc() ) $value = stripslashes( $value ); return mysql_real_escape_string( $value ); } function user_login($username, $password, $cookies=false) { $username = clean_string($username); $password = clean_string($password); $md5password = md5($password); $result = mysql_query("select username from members where username='$username' and md5password='$md5password'"); if (mysql_num_rows($result) != 0) { $_SESSION['auth']['username'] = $username; $_SESSION['auth']['md5password'] = $md5password; if ($cookies) { $expiry = time() + 60 * 60 * 24 * 30; setcookie("username", $username, $expiry); setcookie("md5password", $md5password, $expiry); } return true; } else { return false; } } function user_logout() { unset($_SESSION['auth']); setcookie("username", "", time() - 3600); setcookie("password", "", time() - 3600); } function user_loggedin() { if (isset($_SESSION['auth'])) { $username = $_SESSION['auth']['username']; $md5password = $_SESSION['auth']['md5password']; } else { $username = $_COOKIE['username']); $md5password = $_COOKIE['md5password']; } if ($username == "" || $md5password == "") return false; $result = mysql_query("select username from members where username='$username' and md5password='$md5password'"); if (mysql_num_rows($result) != 0) { return true; } else { return false; } } Thankyou!
  10. Is there some sort of php class that I could employ to find spelling mistakes in a string (english)? I've been searching on the internet but couldn't find anything. I just need it to return true if there is a spelling mistake, false if there isn't. Thanks
  11. Hey everyone! I have a (very) limited knowledge of CMS's in general, and do not even know how this type of thing would work. What I am doing with my site at the moment is having the markup for each page in the PHP file, which works fine, except when I want to change some markup across all the pages.. it means I have to go through 100+ php files and find and change one or two lines or markup, which is very annoying. I thought I might invest the time to find a solution. Due to the nature of my site however, the content is not static. I have a sidebar which lists the latest and highest rated content, and is generated through PHP which contacts my MYSQL database. This sidebar would need to be part of the CMS. Php for this looks kinda like this: <?php $result = mysql_query("select jokedata.id as joke_id, jokedata.joketitle as joke_title, sum(ratings.rating) / count(ratings.rating) as average from jokedata inner join ratings on ratings.content_type = 'joke' and ratings.relative_id = jokedata.id group by jokedata.id order by average desc limit 5"); for ($i = 1; $i <= 5; $i++) { $row = mysql_fetch_array($result); $current_id = $row['joke_id']; $current_title = $row['joke_title']; $current_title = html_entity_decode(ucwords(strtolower($current_title))); echo "<li>&#187; <a href=\"http://www.funpunks.com/funny_jokes/viewjoke.php?id=$current_id\">$current_title</a></li>"; } ?> I have about 5 of those blocks on my sidebar. As well as this, the content on nearly every page is dynamically generated. I know that some CMS's work a little like this: <?php $this_page = mytemplate->load(); $content = "Lorem ipsum tota..."; $this_page = mytemplate->insertcontent($this_page, $content); mytemplate->display($this_page); ?> Or something along those lines. But my 'content' would need to be something like: <?php $content = " <?php $result = mysql_query("SELECT * FROM jokedata"); while ($row = mysql_fetch_array($result)) { ... } " ?> Which doesnt make sense, because then the php would have to be executed twice. So basically what I am asking is, what is a good solution to maintain CSS in one file, markup in another, and dynamically generated content in another? Thanks!
  12. Not Found I'm going to post my whole code here, a short explaination is I am basically trying to build a file renamer/deleter. changetitles.php <?php // get current filename if (isset($_GET['current_filename'])) $current_filename = $_GET['current_filename']; else $current_filename = "0.jpg"; // put all lines from file into an array $files = file('picturelist.txt', FILE_IGNORE_NEW_LINES); // find the value in the array and return the key $key = array_search($current_filename, $files) or exit("Not found"); // assign the value of the next element to var $next_filename = $files[$key+1]; $previous_filename =$files[$key-1]; // if the command save was posted, rename previous image to the image title that was posted if ($_POST['command'] == "save") { $image_title = $_POST['image_title']; $file_directory= "funnyjunk_pictures/"; rename($file_directory.$previous_filename, $file_directory.$image_title.".jpg"); } // if the command delete was posted, delete previous image if ($_POST['command'] == "delete") { $file_directory = "funnyjunk_pictures/"; unlink($file_directory.$previous_filename); } ?> <HTML> <BODY onLoad="self.focus();document.edittitle.image_title.focus()" style="text-align: center"> <div style="width: 800px; border: 1px solid #CCCCCC; text-align: left"> <?php echo " <center><h1>$current_filename</h1><br /> <img src=\"funnyjunk_pictures/$current_filename\" /> <br /> <form name=\"edittitle\" action=\"changetitles.php?current_filename=$next_filename\" method=\"post\"> <input type=\"hidden\" name=\"command\" value=\"save\" /> <input type=\"hidden\" name=\"previous_picture\" value=\"$current_filename\" /> <input type=\"text\" name=\"image_title\" /> <input type=\"submit\" value=\"Save + Next\" /> </form> <br /> <form action=\"changetitles.php?current_filename=$next_filename\" method=\"post\"> <input type=\"hidden\" name=\"command\" value=\"delete\" /> <input type=\"hidden\" name=\"previous_picture\" value=\"$current_filename\" /> <input type=\"submit\" value=\"Delete + Next\" /> </form> </center> "; ?> </div> </BODY> </HTML> Edit: Forgot picturelist.txt 0.jpg 1.jpg 2.jpg 3.jpg 4.jpg 5.jpg 6.jpg 7.jpg 8.jpg 9.jpg 10.jpg 11.jpg 12.jpg 13.jpg 14.jpg 15.jpg 16.jpg 17.jpg 18.jpg 19.jpg 20.jpg 21.jpg 22.jpg 23.jpg 24.jpg 25.jpg 26.jpg 27.jpg 28.jpg 29.jpg 30.jpg 31.jpg 32.jpg 33.jpg 34.jpg 35.jpg 36.jpg 37.jpg 38.jpg 39.jpg 40.jpg 41.jpg 42.jpg 43.jpg 44.jpg 45.jpg 46.jpg 47.jpg 48.jpg 49.jpg 50.jpg 51.jpg 52.jpg 53.jpg 54.jpg 55.jpg 56.jpg 57.jpg 58.jpg 59.jpg 60.jpg 61.jpg 62.jpg 63.jpg 64.jpg 65.jpg 66.jpg 67.jpg 68.jpg 69.jpg 70.jpg 71.jpg 72.jpg 73.jpg 74.jpg 75.jpg 76.jpg 77.jpg 78.jpg 79.jpg 80.jpg 81.jpg 82.jpg 83.jpg 84.jpg 85.jpg 86.jpg 87.jpg 88.jpg 89.jpg 90.jpg 91.jpg 92.jpg 93.jpg 94.jpg 95.jpg 96.jpg 97.jpg 98.jpg 99.jpg 100.jpg 101.jpg 102.jpg 103.jpg 104.jpg 105.jpg 106.jpg 107.jpg 108.jpg 109.jpg 110.jpg 111.jpg 112.jpg 113.jpg 114.jpg 115.jpg 116.jpg 117.jpg 118.jpg 119.jpg 120.jpg 121.jpg 122.jpg 123.jpg 124.jpg 125.jpg 126.jpg 127.jpg 128.jpg 129.jpg 130.jpg 131.jpg 132.jpg 133.jpg 134.jpg 135.jpg 136.jpg 137.jpg 138.jpg 139.jpg 140.jpg 141.jpg 142.jpg 143.jpg 144.jpg 145.jpg 146.jpg 147.jpg 148.jpg 149.jpg 150.jpg 151.jpg 152.jpg 153.jpg 154.jpg 155.jpg 156.jpg 157.jpg 158.jpg 159.jpg 160.jpg 161.jpg 162.jpg 163.jpg 164.jpg 165.jpg 166.jpg 167.jpg 168.jpg 169.jpg 170.jpg 171.jpg 172.jpg 173.jpg 174.jpg 175.jpg 176.jpg 177.jpg 178.jpg 179.jpg 180.jpg 181.jpg 182.jpg 183.jpg 184.jpg 185.jpg 186.jpg 187.jpg 188.jpg 189.jpg 190.jpg 191.jpg 192.jpg 193.jpg 194.jpg 195.jpg 196.jpg 197.jpg 198.jpg 199.jpg 200.jpg 201.jpg 202.jpg 203.jpg 204.jpg 205.jpg 206.jpg 207.jpg 208.jpg 209.jpg 210.jpg 211.jpg 212.jpg 213.jpg 214.jpg 215.jpg 216.jpg 217.jpg 218.jpg 219.jpg 220.jpg 221.jpg 222.jpg 223.jpg 224.jpg 225.jpg 226.jpg 227.jpg 228.jpg 229.jpg 230.jpg 231.jpg 232.jpg 233.jpg 234.jpg 235.jpg 236.jpg 237.jpg 238.jpg 239.jpg 240.jpg 241.jpg 242.jpg 243.jpg 244.jpg 245.jpg 246.jpg 247.jpg 248.jpg 249.jpg 250.jpg 251.jpg 252.jpg 253.jpg 254.jpg 255.jpg 256.jpg 257.jpg 258.jpg 259.jpg 260.jpg 261.jpg 262.jpg 263.jpg 264.jpg 265.jpg
  13. Yes it is, I did a print_r anyway.. Array ( [0] => 0.jpg [1] => 1.jpg [2] => 2.jpg [3] => 3.jpg [4] => 4.jpg [5] => 5.jpg [6] => 6.jpg [7] => 7.jpg [8] => 8.jpg [9] => 9.jpg [10] => 10.jpg [11] => 11.jpg [12] => 12.jpg [13] => 13.jpg [14] => 14.jpg [15] => 15.jpg [16] => 16.jpg [17] => 17.jpg [18] => 18.jpg [19] => 19.jpg [20] => 20.jpg [21] => 21.jpg [22] => 22.jpg [23] => 23.jpg [24] => 24.jpg [25] => 25.jpg [26] => 26.jpg [27] => 27.jpg [28] => 28.jpg [29] => 29.jpg [30] => 30.jpg [31] => 31.jpg [32] => 32.jpg [33] => 33.jpg [34] => 34.jpg [35] => 35.jpg [36] => 36.jpg [37] => 37.jpg [38] => 38.jpg [39] => 39.jpg [40] => 40.jpg [41] => 41.jpg [42] => 42.jpg [43] => 43.jpg [44] => 44.jpg [45] => 45.jpg [46] => 46.jpg [47] => 47.jpg [48] => 48.jpg [49] => 49.jpg [50] => 50.jpg [51] => 51.jpg [52] => 52.jpg [53] => 53.jpg [54] => 54.jpg [55] => 55.jpg [56] => 56.jpg [57] => 57.jpg [58] => 58.jpg [59] => 59.jpg [60] => 60.jpg [61] => 61.jpg [62] => 62.jpg [63] => 63.jpg [64] => 64.jpg [65] => 65.jpg [66] => 66.jpg [67] => 67.jpg [68] => 68.jpg [69] => 69.jpg [70] => 70.jpg [71] => 71.jpg [72] => 72.jpg [73] => 73.jpg [74] => 74.jpg [75] => 75.jpg [76] => 76.jpg [77] => 77.jpg [78] => 78.jpg [79] => 79.jpg [80] => 80.jpg [81] => 81.jpg [82] => 82.jpg [83] => 83.jpg [84] => 84.jpg [85] => 85.jpg [86] => 86.jpg [87] => 87.jpg [88] => 88.jpg [89] => 89.jpg [90] => 90.jpg [91] => 91.jpg [92] => 92.jpg [93] => 93.jpg [94] => 94.jpg [95] => 95.jpg [96] => 96.jpg [97] => 97.jpg [98] => 98.jpg [99] => 99.jpg [100] => 100.jpg [101] => 101.jpg [102] => 102.jpg [103] => 103.jpg [104] => 104.jpg [105] => 105.jpg [106] => 106.jpg [107] => 107.jpg [108] => 108.jpg [109] => 109.jpg [110] => 110.jpg [111] => 111.jpg [112] => 112.jpg [113] => 113.jpg [114] => 114.jpg [115] => 115.jpg [116] => 116.jpg [117] => 117.jpg [118] => 118.jpg [119] => 119.jpg [120] => 120.jpg [121] => 121.jpg [122] => 122.jpg [123] => 123.jpg [124] => 124.jpg [125] => 125.jpg [126] => 126.jpg [127] => 127.jpg [128] => 128.jpg [129] => 129.jpg [130] => 130.jpg [131] => 131.jpg [132] => 132.jpg [133] => 133.jpg [134] => 134.jpg [135] => 135.jpg [136] ...etc
  14. Thanks for the quick reply, however it is always exiting with "Not found" now (A little addition I made to your nice code). Here is the code I have, including getting the current filename. // get current filename if (isset($_GET['current_filename'])) $current_filename = $_GET['current_filename']; else $current_filename = "0.jpg"; // put all lines from file into an array $files = file('picturelist.txt'); // find the value in the array and return the key $key = array_search($current_filename, $files) or exit("Not found"); // assign the value of the next element to var $next_filename = $files[$key+1]; $previous_filename =$files[$key-1]; And this is what "picturelist.txt" looks like: 0.jpg 1.jpg 2.jpg 3.jpg 4.jpg 5.jpg 6.jpg 7.jpg 8.jpg 9.jpg 10.jpg 11.jpg ... Thanks.
×
×
  • 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.