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.

andrewliu

Members
  • Joined

  • Last visited

Everything posted by andrewliu

  1. hmm it seems like it doesnt work? This is my form html <form action="" class="ajax" name="form" style="float:right;width:650px;height:60px;margin-right:30px;" onSubmit="return searchLocations();" > <table style="float:right;"><tr> <td> <label for="testinput"><b>Search</b> <span class="italics">(i.e. chicken breast, Ratatouille, deli):</span></label><br /> </td> <td> <label for="testinput"><b>Location</b></label><br /> </td></tr> <tr> <td> <input name="search_term" type="text" style="height:23px; margin-right:20px;font-size: 16px" value="<?PHP echo $search_term; ?>" size="36" autocomplete="off"/></td> <td> <input name="addressInput" id="addressInput" type="text" style="height:23px;margin-right:10px;font-size: 16px" value="<?PHP echo $location_term; ?>" size="36" autocomplete="off"/></td><td> <select id="radiusSelect"> <option value="25" selected>25 Miles</option> <option value="100">100 Miles</option> <option value="200">200 Miles</option> </select></td><td> <input type="submit" name="search_button" style= "padding: 5px; font-family: Arial, Helvetica, sans-serif; font-size: 12px;" value="Search" onclick="searchLocations();" /> </td></tr></table><br /> </p> </form> and then I used the script u wrote up, but not sure what to put in the url, data, type? $(document).ready(function(){ $("form.ajax").submit(function(){ var ajax_div = $(this).attr("id")+"_results"; var data = $(this).serialize(); var url = $(this).attr("action"); var type = $(this).attr("method").toUpperCase(); $.ajax({ url: url, data: data, type: type, success: function(data){ $("#"+ajax_div).html(data); } }); return false; }); }); and then I made a div id tag around my results Thanks!
  2. Hello. I have a search engine form that is not ajax and it refreshes the page on search. I was wondering if it is possible to type a onclick code where it will contain my php script for the search engine by when you search, it'll send show the result in a div tag? If this is possible, can someone help me get started. I'm a very beginner at ajax. Thank you
  3. Hello. I'm a newbie at javascript. I have a code where a function has a name lets say, function get() and this function outputs a result from a form when a user submits something. Now I was wondering if I can type another function get() to create another script that does something else when the form gets submitted? Thanks
  4. Also, I think my search doesn't get passed to the next page. Any idea how to preserve that?
  5. Hello, I got my search engine working and it does show the number of results including the number of pages it should have. But I'm having trouble outputting the results when I click next. When I click the next page it doesn't show any results. <?PHP global $search_term; global $location_term; global $results; function getmicrotime() { list($usec, $sec) = explode(" ", microtime()); return ((float)$usec + (float)$sec); } $connection_string = "connectionstring.php"; require_once($connection_string); mysql_select_db("chef") or die ( 'Unable to select database.' ); $RESULTS_LIMIT=10; if(isset($_GET['search_term']) && isset($_GET['location_term']) && isset($_GET['search_button'])) { $search_term = $_GET['search_term']; $location_term = $_GET['location_term']; if(!isset($first_pos)) { $first_pos = "0"; } $start_search = getmicrotime(); $sql_query = mysql_query("SELECT * FROM searchengine WHERE MATCH(product) AGAINST('$search_term') AND MATCH(location) AGAINST('$location_term')"); if($results = mysql_num_rows($sql_query) != 0) { $sql = "SELECT * FROM searchengine WHERE MATCH(product) AGAINST('$search_term') AND MATCH(location) AGAINST('$location_term') LIMIT $first_pos, $RESULTS_LIMIT"; $sql_result_query = mysql_query($sql); } else { $sql = "SELECT * FROM searchengine WHERE (product LIKE '%".mysql_real_escape_string($search_term)."%' AND location LIKE '%".mysql_real_escape_string($location_term)."%') "; $sql_query = mysql_query($sql); $results = mysql_num_rows($sql_query); $sql_result_query = mysql_query("SELECT * FROM searchengine WHERE (product LIKE '%".$search_term."%' AND location LIKE '%".$location_term."%') LIMIT $first_pos, $RESULTS_LIMIT "); } $stop_search = getmicrotime(); $time_search = ($stop_search - $start_search); } ?> <?PHP global $first_pos; global $sites; if($first_pos > 0) { $back=$first_pos-$RESULTS_LIMIT; if($back < 0) { $back = 0; } echo "<a href='index2.php?search_term=".stripslashes($search_term)."&first_pos=$back' ></a>"; } if($results>$RESULTS_LIMIT) { $sites=intval($results/$RESULTS_LIMIT); if($results%$RESULTS_LIMIT) { $sites++; } } for ($i=1;$i<=$sites;$i++) { $fwd=($i-1)*$RESULTS_LIMIT; if($fwd == $first_pos) { echo "<a href='index2.php?search_term=".stripslashes($search_term)."&first_pos=$fwd '><b>$i</b></a> | "; } else { echo "<a href='index2.php?search_term=".stripslashes($search_term)."&first_pos=$fwd '>$i</a> | "; } } if(isset($first_pos) && $first_pos < $results-$RESULTS_LIMIT) { $fwd=$first_pos+$RESULTS_LIMIT; echo "<a href='index2.php?search_term=".stripslashes($search_term)."&first_pos=$fwd ' > >></a>"; $fwd=$results-$RESULTS_LIMIT; } ?> Can anyone help me out on this? Thanks
  6. hello, I was wondering if anyone can tell me why this script won't allow me to show my images? <?php $files = glob("/1m/{*.gif,*.jpg,*.png}", GLOB_BRACE); for ($i=1; $i<=count($files); $i++) { $num = $files[$i]; echo '<img src="'.$num.'" alt="1minute">'." "; } ?> The script will work if I put an image in the same folder as my .php file $files = glob("*"); But I want my image in another director, or only upload .jpg files. Thanks
  7. I just added #pop1 { display:none; position:absolute; z-index:100; } It pops out like I wanted it to, but it doesn't allow me to move the table. I want to be able to use the top of the box to move the table.
  8. have you heard of yelp.com? If you check this site out: http://www.yelp.com/search?find_desc=restaurants&ns=1&find_loc=los+angeles and theres a section where you can refine your search, and there are "more..." if you click on that, a small pop up will show. The user will try to find a pop up if the user is trying to click a link to find more categories. is that a dialog box? I'm not sure the term for it. I'm very new to this. Thanks!
  9. Hi, Thanks for responding. I don't want it to stay on the page. I would like the list to pop out a window. However, I don't want it to pop out the normal window where it shows the windows bar and URL. I would like a div table to pop out. Thanks
  10. Hello, I'm trying to create a list of categories and have a link with "more categories" and when a user clicks on it, a div table pop up will show. So far I've hidden a div tag and had it show and close if a user clicks on the link. But its not a pop up. I was wondering if anyone can help me modify my code where it will pop up. But also, be able to drag the pop up from the top of the table. Here is what I have so far. <script type="text/javascript"> function pop(div) { document.getElementById(div).style.display='block'; return false } function hide(div) { document.getElementById(div).style.display='none'; return false }</script> <a href="#" onclick="return pop('pop1');">more...</a> <a href="#" onClick="return hide('pop1')">Close</a> Thanks!
  11. Hello, I'm trying to build a list of categories and I don't want to overflow my tables, so I was wondering if anyone has a code that will allow users to click on a link and a pop up will show the rest of the list. I would like the user to drag it as well so it won't get in the way of the web site's contents. Thanks
  12. Hello. I was looking into this google tutorial: http://code.google.com/apis/maps/articles/phpsqlsearch.html#findnearsql and its what I wanted it to do. Calculate a nearby store locator. But I was curious about how to modify it by instead of outputting the data like it in the tutorial, but outputting against some kind of search term like in yelp.com where if you search a restaurant and have location, it will output nearby restaurants from their database Thank you
  13. great! thanks guys!
  14. Yeah thats perfect! Thanks!
  15. Like i was looking at the tutorial example and it had [{"latitude":"39.994972","longitude":"-83.007027"},{"latitude":"40.144711","longitude":"-82.990883"}, etc...] It had the [{ and the quotes with the : appreciate your help!
  16. Oh thats great! Thank! One last modification, I wanted to have [, {, ", and the : but since I'm still new to php, I'm not sure how code this without getting an error Thanks again!
  17. Thanks for the response! I'm getting a undefined variable on longitude and latitude. Am I supposed to write some if isset statement somewhere or if empty statement? I'm new to php sorry Thanks
  18. Hello, I was wondering what the script was to output an array: [{"latitude":"39.994972","longitude":"-83.007027"},{"latitude":"40.144711","longitude":"-82.990883"}, etc...] I have a database with the name "lat" and "lng" I'm trying to follow a script that can tell me a user's distance from a store, but I need a php script where I can grab the information from my database and output it. I'm following this tutorial: http://www.developer.com/services/article.php/10928_3862051_2/Create-Your-Own-Store-Locator-with-Google-Maps-PHP-and-MySQL.htm and I need a load-location.php, and when I looked at the demo : http://maps.wjgilmore.com/locator/index.html I checked the script and saw that the load-location.php is just a list of locations. Thanks for helping
  19. Hello, This might be an easy solution for you guys, but I'm learning php on my own and I'm having problems with this code. Its giving me an output of what I want but I'm also getting this error "Notice: Undefined variable: construct in C:\wamp\www\search_exp\data.php on line 27" the line 27 is on the first $construct line. <?php mysql_connect("localhost","root","");// mysql_select_db("chef"); $product_search = mysql_real_escape_string($_POST['product_search']); //$result = mysql_query("SELECT product FROM searchengine WHERE product='$product_search'"); //$result_num_rows = mysql_num_rows($result); //this checks for fales (0) or true (1). if ($product_search==NULL) { echo "Please enter an ingredient or dish"; } else { echo "You searched for <b>$product_search</b><hr size='1'>"; $search_exploded = explode(" ", $product_search); $x = 0; foreach($search_exploded as $search_each) { //construct query $x++; if ($x==1) { $construct .= "product LIKE '%" .$search_each. "%'";} else{ $construct .= "OR product LIKE '%" .$search_each. "%'";} // } //$product_search = 0; //while ($product_search < count($search_exploded)) { /*if ($product_search == 0) { $construct = "product LIKE '%" . $product_search . "%'"; } else { $construct .= "OR product LIKE '%" . $product_search . "%'"; } $product_search++; }*/ } $construct = "SELECT * FROM searchengine WHERE $construct"; $run = mysql_query($construct); $found = mysql_num_rows($run); if ($found==0) echo "Sorry, cannot find ingredient or dish. If you like to contribute, you can submit an ingredient or dish that you think will be useful"; else { echo "$found results found!<p>"; while ($runrows = mysql_fetch_assoc($run)) { //get data $store = $runrows['store']; $product = $runrows['product']; $description = $runrows['description']; //$price = $runrows['price']; //$saving = $runrows['saving']; //$distance = $runrows['distance']; echo " <b>$store</b><br> Product: $product<br> Description: $description<p>"; } }} ?> Then when I tried inputting this code: $construct=""; if ($x==1) { $construct .= "product LIKE '%" .$search_each. "%'"; }else{ $construct .= "OR product LIKE '%" .$search_each. "%'"; } I get an error: "Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\search_exp\data.php on line 48" and line 48 is here: $found = mysql_num_rows($run);" And then, its not giving me my search results, it comes out saying that "Sorry, cannot find ingredient or dish. If you like to contribute, you can submit an ingredient or dish that you think will be useful"
  20. so the this technique is written in python? being able to get other content is not php script?
  21. Hello, I was wondering if it is do able to grab certain contents from other websites such as coupon deals? Since deals come and go, but if you know the website where they advertise the coupons, is it possible where you can write a script and have it saved into your mysql database? Thanks
  22. nevermind. I figure it out, if anyone else is having the same problems change this $query .= "WHERE menu_name=" . '$page_id' ." "; to $query .= "WHERE menu_name="' . $page_id . "'";
  23. Hello. I'm creating links with php and mysql. When I have my links up, some of the links get an error "Database query failed: Unknown column 'jobs' in 'where clause'" and some gets a "Database query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'us LIMIT 1' at line 1" Well to be specific, I'm making 3 menu columns, and under each column, theres only 1 link that gets the LIMIT 1 error, and the rest of the links in the column gets the unknown column error. Can anyone take a look at my code? The problem might be coming from here function get_page_name($page_id) { global $connection; $query = "SELECT * "; $query .= "FROM pages "; $query .= "WHERE menu_name=" . '$page_id' ." "; $query .= "LIMIT 1"; $result_set = mysql_query($query, $connection); confirm_query($result_set); // REMEMBER: // if no rows are returned, fetch_array will return false if ($page_set = mysql_fetch_array($result_set)) { return $page_set; } else { return NULL; } } here's a code for one of the links echo "<div class=\"first_box\">"; echo "<h4>about</h4>"; echo "<ul class=\"subject\">"; //rebuilding my layout (links section) $subject_set = get_all_subjects(); while ($subject = mysql_fetch_array($subject_set)) { $page_set = get_pages_for_subject($subject['menu_name']); while ($page = mysql_fetch_array($page_set)) { if ('about' == $page['subject_id']) { echo "<li><a href=\"..\content.php?page=" . urlencode($page["menu_name"]) . "\">{$page['menu_name']}</a></li>"; } } } thanks!!
  24. Hello everyone! I was wondering if anyone can direct me to a good source or has a script where if the user inputs his/her zip code, the website should now know the user's location so then when they search for stores, the search will direct to a store nearby them? Thanks
  25. Because I want to learn building a site on my own. Starting from scratch can enhance my knowledge at a faster rate. I think wordpress is limited to what I'm trying to accomplish. I've also gotten my lynda.com tutorials on php with mysql... I won't be here for awhile! Thanks everyone for all the contribution

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.