Jump to content

thara

Members
  • Posts

    604
  • Joined

Everything posted by thara

  1. $q = "SELECT keyword, col, city_name, image_name, tutor_code FROM ( SELECT tutor_name AS keyword, 'Tutors' AS col, IFNULL(c1.city_name, '') city_name, IFNULL(ti.image_name, '') image_name, tutor_code FROM tutors AS t LEFT JOIN address a ON t.address_id = a.address_id LEFT JOIN city c1 ON a.city_id = c1.city_id LEFT JOIN tutor_images ti ON t.tutor_id = ti.tutor_id WHERE ti.image_type = 'profile' UNION SELECT subjects AS keyword, 'Subject' AS col, '' city_name, '' image_name, '' tutor_code FROM subject UNION SELECT city_name AS keyword, 'City' AS col, '' city_name, '' image_name, '' tutor_code FROM city UNION SELECT institute_name AS keyword, 'Institute' AS col, '' city_name, '' image_name, '' tutor_code FROM institutes ) s WHERE keyword LIKE '%$queryString%' LIMIT 10"; this query display a list with subjects, tutor names, cities and institutes according the keyword. This is working but If tutors dont have a profile image those tutors not display in the list.. can anybody you tell me why is it? Thanks
  2. Hello.. In my search bar I used jquery auto complete function to display related result for the searching keyword. It is working perfectly and now I'm looking for a way to increase the usability of it.. this is so far from my database file... <?php require_once('database.php'); if(isset($_POST['queryString'])) { $queryString = $dbc->real_escape_string($_POST['queryString']); if(strlen($queryString) >0) { $q = "SELECT keyword FROM ( SELECT tname AS keyword FROM t UNION SELECT sname AS keyword FROM sub UNION SELECT cname AS keyword FROM c UNION SELECT iname AS keyword FROM i ) s WHERE keyword LIKE '%$queryString%' LIMIT 10"; $r = mysqli_query ( $dbc, $q); if($q) { while ($row = mysqli_fetch_array($r, MYSQL_ASSOC)) { echo '<li onclick="fill(\''.$row['keyword'].'\');">'.$row['keyword'].'</li>'; } } else { echo 'ERROR: There was a problem with the query.'; } } else { } } else { echo 'There should be no direct access to this script!'; } ?> This is from my index page with jquery <script type="text/javascript" src="jquery-1.7.1.js"></script> <script type="text/javascript"> function lookup(inputString) { if(inputString.length == 0) { $('#suggestions').hide(); } else { $.post("rpc.php", {queryString: ""+inputString+""}, function(data){ if(data.length >0) { $('#suggestions').show(); $('#autoSuggestionsList').html(data); } }); } } function fill(thisValue) { $('#inputString').val(thisValue); setTimeout("$('#suggestions').hide();", 200); } </script> My problem is auto complete box display all values all together in this case subjects, tutor names, institutes names, city etc. So I'd like the results from the autocomplete function to be separated into categories. For example, if a user starts typing "an", the autocomplete will show 4 categories with items in each. if a user wants to select one of the items in the list under category "Subject". can any body tell me how can I do this? any comments are greatly appreciated. Thank you.
  3. I have added search bar to my project and checking multiple criteria through that searching text box. In there, user can enter their searching subject, their searching tutor's name, preferred city or their searching institute.. Then I am getting that searching word into a variable.. it is '$searchString'. Now I need to create a query to display search results... and I tried it like this.. $q = "SELECT tcs.tutor_id AS tid, tcs.category_id AS cid, tcs.subject_id AS sid, GROUP_CONCAT( DISTINCT s.subjects SEPARATOR ', ') AS subjects, t.tutor_name AS tname, t.tutor_code AS tcode, DATE_FORMAT(t.registration_date, '%b %D, %Y') AS date, t.qualification AS qualifi, GROUP_CONCAT( DISTINCT o.option_name SEPARATOR ', ') AS tutor_option, timg.image_name AS img, city_name AS city, d.district_name AS district FROM tutor_category_subject as tcs INNER JOIN subject AS s ON tcs.subject_id = s.subject_id INNER JOIN tutor_option AS toption ON toption.tutor_id = tcs.tutor_id INNER JOIN options AS o ON toption.option_id = o.option_id INNER JOIN tutors AS t ON tcs.tutor_id = t.tutor_id INNER JOIN address ON address.address_id = t.address_id INNER JOIN city ON city.city_id = address.city_id INNER JOIN district AS d ON d.district_id = city.district_id LEFT JOIN tutor_images AS timg ON timg.tutor_id = tcs.tutor_id AND timg.image_type = 'profile' WHERE t.tutor_id IN (SELECT t2.tutor_id FROM tutors AS t2 INNER JOIN tutor_category_subject AS tcs2 ON tcs2.tutor_id = t2.tutor_id JOIN subject AS s2 ON s2.subject_id = tcs2.subject_id WHERE s2.subjects LIKE '$searchSting') GROUP BY tcs.tutor_id LIMIT $start, $display"; This query is working only if a user is searching a subject. My problem is I need to check if a user is searching a particular tutor by giving a tutor name or searching a city by giving a city name or typing an institute name to search an institute in search text box. So can I know how can I find what is the value $searchString have and how to create the query with this variable value.. I tried it with some changing in my sub query's where clause. it is something like this... WHERE (s2.subjects LIKE '$searchSting' OR t.tname LIKE '$searchString' OR city.city LIKE '$seachString') But it is not working.. can anybody help me to fix this problem? Thank you...
  4. What is the problem that you have faced with this script? Is there any errors?
  5. Try something like this... if ($_POST["email"] && !preg_match ('/^[\w.-]+@[\w.-]+\.[AZa-z]{2,6}$/', $_POST['email']))
  6. Update the script with this code.. (in page linking section) // If it's not the first page, make a Previous button: if ($current_page != 1) { echo '<a href="products.php?s=' . ($start - $display) . '&p=' . $pages . '">Previous</a> '; } // Make all the numbered pages: for ($i = 1; $i <= $pages; $i++) { if ($i != $current_page) { echo '<a href="products.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> '; } else { echo $i . ' '; } } // End of FOR loop. // If it's not the last page, make a Next button: if ($current_page != $pages) { echo '<a href="products.php?s=' . ($start + $display) . '&p=' . $pages . '">Next</a>'; } echo '</p>'; // Close the paragraph.
  7. @Muddy_Funster... you are correct. I couldn't mentioned to OP about it.. @arunpatal try to understand the difference.. Here I use mysql functions with mysqli extension. These functions provide improved performance and take advantage of added features (among other benefits).
  8. This is a good practice code for your connection.php page.. <?php // This file also establishes a connection to MySQL // and selects the database. // Set the database access information as constants: DEFINE ('DB_USER', 'username'); DEFINE ('DB_PASSWORD', 'password'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'sitename'); // Make the connection: $link = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() ); ?> try with this...
  9. when you creating a connection with mysql always use a variable to keep the connection. If the connection was made, the variable, short for database connection, will become a reference point for all of your subsequent database interactions. Most of the PHP functions for working with MySQL will take this variable as its first argument.
  10. How those information exist in your 'connect_to_mysql.php' page... In that script this connections info must have something similar to this.. $link = mysqli_connect("localhost", "my_user", "my_password" ); if so.... then mysql query should be.. $r = mysqli_query( $link, $q);
  11. oh.. its a mistake.. and just add your db connection there... $r = mysqli_query($your-connection, $q); refer this : http://php.net/manual/en/mysqli.query.php
  12. I modified the code with your product.php page. This is the complete script and you do need to nothing with it.. <?php // Script Error Reporting error_reporting(E_ALL); ini_set('display_errors', '1'); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Store Home Page</title> <link rel="stylesheet" href="style/style.css" type="text/css" media="screen" /> </head> <body> <script language=Javascript> <!-- var itv = 50; var step = 10; var start = 0; var end = 0; var currentOpac; //change the opacity for different browsers function changeOpac(obj, opacity) { var object = obj.style; object.opacity = (opacity / 100); object.MozOpacity = (opacity / 100); object.KhtmlOpacity = (opacity / 100); object.filter = "alpha(opacity=" + opacity + ")"; } function BeginOpacity(obj, s, e) { start = s; end = e; currentOpac = s; theobject=obj; changing=setInterval("opacityit(theobject)",itv); } function EndOpacity(obj, end){ clearInterval(changing); changeOpac(obj, end); } function opacityit(obj){ if(start > end) { if (currentOpac>end){ currentOpac = currentOpac - step; changeOpac(obj,currentOpac); } else if (window.highlighting) clearInterval(highlighting); } else if(start < end) { if (currentOpac<end){ currentOpac = currentOpac + step; changeOpac(obj,currentOpac); } else if (window.changing) clearInterval(changing); } } //--> </script> <div align="center" id="mainWrapper"> <?php include_once("viks2007_header.php");?></div > <table id="products_page_maintable"> <tr> <td id="left_products_td" valign="top"> <h3 id="left_products_td_headline">Latest Designer Fashions</h3> <?php // Connect to the MySQL database include "viks2007_script/connect_to_mysql.php"; $display = 10; // Determine how many pages there are... if (isset($_GET['p']) && is_numeric ($_GET['p'])) { // Already been determined. $pages = $_GET['p']; } else { // Need to determine. // Count the number of records: $q = "SELECT COUNT( id ) FROM product AS p"; $r = @mysqli_query ($dbc, $q); $row = @mysqli_fetch_array ($r, MYSQLI_NUM); $records = $row[0]; // Calculate the number of pages... if ($records > $display) { // More than 1 page. $pages = ceil ($records/$display); } else { $pages = 1; } } // End of p IF. // Determine where in the database to start returning results... if (isset($_GET['s']) && is_numeric($_GET['s'])) { $start = $_GET['s']; } else { $start = 0; } $q = "SELECT * FROM product ORDER BY date_added DESC LIMIT $start, $display"; $r = mysqli_query( $dbc, $q); if ( mysqli_num_rows($r) >= 1) { while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC)) { $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); echo '<div style="float:left;"> <p align="center"><a href="product_detail.php?id=' . $id . '"> <img style="border:#666 1px solid;" src="product_images/' . $id . '.jpg" title=" ' . $product_name . '" alt=" ' . $product_name . '" width="80" height="105" border="1" hspace="10" vspace="10" style="FILTER: alpha(opacity=100);-moz-opacity: 1.0; opacity: 1.0;" onmouseover=BeginOpacity(this,100,40) onmouseout=EndOpacity(this,100) /></a><br />' . $product_name . '</div>'; } } else { echo 'We have no products listed in our store yet'; } // Make the links to other pages, if necessary. if ($pages > 1) { echo '<p>'; // Determine what page the script is on: $current_page = ($start/$display) + 1; // If it's not the first page, make a Previous link: if ($current_page != 1) { echo '<a href="products.php?s=' . ($start - $display) . '&p=' . $pages . '"><</a>'; } // Make all the numbered pages: for ($i = 1; $i <= $pages; $i++) { if ($i != $current_page) { echo '<a href="products.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> '; } else { echo $i; } } // End of FOR loop. // If it's not the last page, make a Next button: if ($current_page != $pages) { echo '<a href="products.php?s=' . ($start + $display) . '&p=' . $pages . '">></a>'; } echo '</p>'; // Close the paragraph. } // End of links section. ?> </td> <td id="right_products_td" valign="top"> <h3 id="right_products_td_headline">Handy Tips</h3> If you operate any store online you should read the documentation provided to you by the online payment gateway you choose for handling the checkout process. You can get much more insight than I can offer on the various details of a gateway, from the gateway providers themselves. They are there to help you with whatever you need since they get a cut of your online business dealings. </td> </tr> </table> </div> <?php include_once("viks2007_footer.php");?> </div> </body> </html>
  13. This is exactly you are looking for.. I coded this but not checked. This should be work with some minor modification or not.. <?php $display = 10; // Determine how many pages there are... if (isset($_GET['p']) && is_numeric ($_GET['p'])) { // Already been determined. $pages = $_GET['p']; } else { // Need to determine. // Count the number of records: $q = "SELECT COUNT( id ) FROM product AS p"; $r = @mysqli_query ($dbc, $q); $row = @mysqli_fetch_array ($r, MYSQLI_NUM); $records = $row[0]; // Calculate the number of pages... if ($records > $display) { // More than 1 page. $pages = ceil ($records/$display); } else { $pages = 1; } } // End of p IF. // Determine where in the database to start returning results... if (isset($_GET['s']) && is_numeric($_GET['s'])) { $start = $_GET['s']; } else { $start = 0; } $q = "SELECT * FROM product ORDER BY date_added DESC LIMIT $start, $display"; $r = mysqli_query( $dbc, $q); if ( mysqli_num_rows($r) >= 1) { while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC)) { $id = $row["id"]; $product_name = $row["product_name"]; $price = $row["price"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); echo '<div style="float:left;"> <p align="center"><a href="product_detail.php?id=' . $id . '"> <img style="border:#666 1px solid;" src="product_images/' . $id . '.jpg" title=" ' . $product_name . '" alt=" ' . $product_name . '" width="80" height="105" border="1" hspace="10" vspace="10" style="FILTER: alpha(opacity=100);-moz-opacity: 1.0; opacity: 1.0;" onmouseover=BeginOpacity(this,100,40) onmouseout=EndOpacity(this,100) /></a><br />' . $product_name . '</div>'; } } else { echo 'We have no products listed in our store yet'; } // Make the links to other pages, if necessary. if ($pages > 1) { echo '<p>'; // Determine what page the script is on: $current_page = ($start/$display) + 1; // If it's not the first page, make a Previous link: if ($current_page != 1) { echo '<a href="products.php?s=' . ($start - $display) . '&p=' . $pages . '"><</a>'; } // Make all the numbered pages: for ($i = 1; $i <= $pages; $i++) { if ($i != $current_page) { echo '<a href="products.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a> '; } else { echo $i; } } // End of FOR loop. // If it's not the last page, make a Next button: if ($current_page != $pages) { echo '<a href="products.php?s=' . ($start + $display) . '&p=' . $pages . '">></a>'; } echo '</p>'; // Close the paragraph. } // End of links section. ?>
  14. show me your product table too...
  15. Problem must be in your sql query.. Try with printing a debugging message after query execution. You can do it something like this... // Debugging message: echo '<p>' . mysqli_error($db) . '<br /><br />Query: ' . $sql . '</p>'; This will print your query and its errors
  16. here you need to get a solution with the pagination. Pagination is a concept you’re familiar with even if you don’t know the term. When you use a search engine like Google, it displays the results as a series of pages and not as one long list. Here in your script could benefit from this same feature. This link will help you to learn the subject.. http://www.phpfreaks.com/tutorial/basic-pagination
  17. jquery will help you to do this....
  18. try with single quotes if (isset($_POST['buton1'])){ $data = $_POST['x']; echo $data; }
  19. Is there any error message with your select menu? If so, show us. If your select query ok, this code should be work...
  20. yes what does mean $friend = $row['follow']; why you use 'username' column in both table?
  21. thara

    Vanity Urls

    what do you need to do? what is your problem?
  22. you are passing post id through result.php page and it gets in details.php page. so how many result come to details.php page with post id? You have mentioned that so many posting in result page and there is a link to details page for more information. so do you need to add pagination to your result page or details page..?
  23. I think Barand has missed something in his post.. I think query should something similar to this.. SELECT * FROM friends AS f INNER JOIN posts AS p ON p.username = f.follow WHERE f.username = '$username' This is not suit for you.. explain your 2 tables with columns...
×
×
  • 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.