Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Daemon Byte

Members
  • Joined

  • Last visited

Everything posted by Daemon Byte

  1. I tend to write code that's more generic. By using an array like I did it allows you to reuse the function with any array you like and you don't have to alter the function. It also means if you do want to alter that html line it's only one line instead of who knows how many lines. There is no reason specifically to do it. I just prefer it personally.
  2. gah why are you using fetch object? I totally missed that. use fetch assoc. while($myrow = mysql_fetch_object($result)) to while($myrow = mysql_fetch_assoc($result)) you might want to drop the second appearance of echo '<h1>Search Database!</h1>'; as well :-)
  3. You don't need the is empty. I found the problem. if($searchwords) /// CHECK SEARCH HAVE BEEN FILLED IN $whatsediterror[1]='<p class="style1"> Please search for something</p>'; should be if(!$searchwords) /// CHECK SEARCH HAVE BEEN FILLED IN echo '<p class="style1"> Please search for something</p>';
  4. on line 33 swap $searchby = (isset($_GET['searchby'])?NULL:mysql_escape_string($_GET['searchby'])); to $searchby = (isset($_GET['searchby'])?mysql_escape_string($_GET['searchby']):false); I got the if the wrong way around :-)
  5. ok that was full of problems so try this. <?php error_reporting(E_ALL); /************************** change to match your connection method ********************/ require_once ('../mysql_connect.php'); // Connect to the db. // Create the search function: function searchForm($select, $searchwords='') { // Re-usable form // variable setup for the form. echo '<form method="get" action="'.$_SERVER['PHP_SELF'].'">'; echo '<input type="hidden" name="cmd" value="search" />'; echo 'Search for: <input type="text" name="words" value="'.$searchwords.'" /> '; echo 'in'; echo '<select name="searchby">'; foreach ($select as $id => $value) echo '<option value="'.$id.'">'.$value.'</option>'; echo '</select> '; echo '<input type="submit" value="Search" />'; echo '</form>'; } /************************************** END OF FUNCTION *****************************************************/ $searchwords = (isset($_GET['words']) ? htmlspecialchars(stripslashes($_REQUEST['words'])) : false); $searchby = (isset($_GET['searchby'])? NULL : mysql_escape_string($_GET['searchby'])); $list = array( 'fname' => 'First Name', 'lname' => 'Last Name', 'details' => 'Details', 'age' => 'Age', 'location' => 'Location', 'email' => 'Email' ); echo '<h1>Search Database!</h1>'; searchForm($list, $searchwords); if(isset($_GET['cmd'])) { ///// CHECK SEARCH WHEN SUMBMITTED if($searchwords) /// CHECK SEARCH HAVE BEEN FILLED IN $whatsediterror[1]='<p class="style1"> Please search for something</p>'; else { $sql = "SELECT * FROM users WHERE {$searchby} LIKE '%{$searchwords}%'"; $result = mysql_query($sql) or die($sql.'<br /><hr /><br />'.mysql_error()); echo '<hr size="1" />'; if(mysql_num_rows($result)>0) { echo '<table align="center" cellspacing="0" cellpadding="5">'; while($myrow = mysql_fetch_object($result)) { echo'<tr><td><span>' .$myrow['fname'] .'</td><td>'. $myrow['lname'] . ' </td><td>'. $myrow['email'] .'</td><td>'. $myrow['location'] . ' </span></td></tr>'; } echo '</table>'; } else { echo '<h1>Search Database!</h1>'; echo "no results found! Try again!"; } } } ?>
  6. I will have to alter my forms accordingly :-)
  7. I've made some changes. <?php // Full-Text Search Example /************************** change to match your connection method ********************/ require_once ('../mysql_connect.php'); // Connect to the db. // create variables for the db $firstn='fname'; $lastn='lname'; $details='details'; $age='age'; $location='location'; $email='email'; // Create the search function: function searchForm() { // Re-usable form // variable setup for the form. $searchwords = (isset($_GET['words']) ? htmlspecialchars(stripslashes($_REQUEST['words'])) : ''); $searchby = (isset($_GET['searchby'])? NULL : $_GET['searchby']); echo '<form method="get" action="'.$_SERVER['PHP_SELF'].'">'; echo '<input type="hidden" name="cmd" value="search" />'; echo 'Search for: <input type="text" name="words" value="'.$searchwords.'" /> '; echo 'in'; echo '<select name="searchby">'; echo '<option value="fname"'.$firstn.'>First Name</option>'; echo '<option value="lname"'.$lastn.'>Last Name</option>'; echo '<option value="details"'.$details.'>Details</option>'; echo '<option value="age"'.$age.'>Age</option>'; echo '<option value="location"'.$location.'>Location</option>'; echo '<option value="email"'.$email.'>Email</option>'; echo '</select> '; echo '<input type="submit" value="Search" />'; echo '</form>'; } // Create the navigation switch $cmd = (isset($_GET['cmd']) ? $_GET['cmd'] : ''); switch($cmd) { default: echo '<h1>Search Database!</h1>'; searchForm(); break; case "search": searchForm(); echo '<h3>Search Results:</h3><br />'; $searchstring = mysql_escape_string($_GET['words']); $sql = "SELECT * FROM users WHERE {$searchby} LIKE '%{$searchstring}%'"; // echo $sql; $result = mysql_query($sql) or die ($sql.'<br /><hr /><br />'.mysql_error()); while($myrow = mysql_fetch_object($result)) { echo '<hr size="1" />'; echo '<table align="center" cellspacing="0" cellpadding="5">'; echo'<td><span>' .$myrow['fname'] .'</td><td>'. $myrow['lname'] .' </td><td>'. $myrow['email'] .'</td><td>'. $myrow['location'] .' </span></td>'; echo '</tr>'; echo '</table>'; } break; } ?> </body> </html> That should stick with your original switch command although I'm not sure why you used that and get rid of the empty query. I hope it's right anyway
  8. the is_numeric was a way to automate the search without the drop. like if it's a number then you search age not first name. I'm not sure what your problem is. can you describe it better or supply a url/screen shot?
  9. ok just for you I've set it up so the doc type changes to xhtml1.0 if it's sending it as text. :-) having huge problems trying to get the float center to work if anyone could help?
  10. you might only be searching for half an email so no @ but something is needed to split it up. searching every when it's not needed is extreme
  11. Well I'm not writing off IE just because microsoft are idiots and can't be bothered to support xhtml. Nore am I going to stop using xhtml just because IE says so. As such I'm going to keep using my method however I will use content negotiation
  12. no you'll have to do them one at a time like this $sql = "SELECT * FROM users WHERE fname LIKE '%{$searchstring}%' OR lname LIKE '%{$searchstring}%' OR details LIKE '%{$searchstring}%' OR age LIKE '%{$searchstring}%' OR location LIKE '%{$searchstring}%' OR email LIKE '%{$searchstring}%'"; Still that seems pretty big. Does the search really have to go through it all? It could be better to have a drop down menu of fields so the person can focus the search
  13. maybe it's the difference between coders and designers? I did put an image on the homepage but I don't think it's to bad now. It's not as embarassing as it used to me anyway
  14. I love lego and that just rocks
  15. I love that site. it's really well put together. oddly I dont like the site of the people that made it
  16. turning my website into a giant picture isn't going to happen. I think the look of yours but I don't do lots images for many reasons.
  17. you're using IE yeh? I'm only asking because I have this code in my page if (strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) $type = 'text/html'; else $type = 'application/xhtml+xml'; header("Content-type: {$type}"); It only gets sent as text to IE7 because IE7 will not render the correct type
  18. Sorted the jumping buttons but I can't figure out those white lines in firefox. anyone got any ideas?
  19. I know it's plain but that's just the way I end up designing. It's not my strongest point. Basically the site will be for the overall thing but I'm planning on getting a designer on board but until then I'm stuck with just me :-) I am working on a logo but that's going to take me forever :-) You should have seen it before though. No shadow on the box more the chess picture. Thanks for pointing out the white lines. They are it seems a FF issue since it doesn't appear on opera either but I didn't notice them in testing so I'll have to track them down. I did plan on centring it all but I couldn't get float left and margin auto to work so I manually centred it for my resolution of 1024 x 768 but if you know how to get the floating centre to work that'd be great.
  20. have you thought about using the mysql like command? say you are looking for a field in the database that contains the word FINDME you would use this sql $word = 'FINDME'; $sql = "SELECT * FROM mytable WHERE myfield LIKE '%{$word}%'"; Sure you can fit that into your code. see if it works better than match
  21. I'm a developer and hate design but I decided to remake my site so any feedback would be gratefully recieved http://www.neverg.co.uk/index.php
  22. but penguin if it's a shared hoster that won't work because the virtual host on apache wont know which website to load. As mentioned he needs a static ip address. I'm sure fasthost will sell you one. I've got a static ip but that was for my ssl
  23. it's still on your machine anyway so it's just an extra risk. Anyway I fear we've hijacked the thread

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.