Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. What you are looking for is called pagination. We have a tutorial here called Basic Pagination. I would suggest reading through that and trying it. If you come across any issues etc, feel free to post them here.
  2. With a query like this, you will need to use sub-queries to create a view of sorts, if either of those terms are foreign to you, I would look them up. Given that this is from a book it should have already explained that... So let me explain what is going on, since you have 2 id's in the movie table that you need to fetch from 1 table you have to sort of run 2 separate queries, since for the obvious you cannot pull out 2 different rows from 1 table in 1 query persay. What you have to do is pull the data and create a "view" what a view is basically a table created from current data in the database and it acts like a temporary table for you to be able to use to pull some data out of like it was coming out of a table. SELECT movie_name, lead.movie_leadactor, director.movie_director FROM (SELECT people_id, people_fullname AS movie_leadactor FROM people WHERE people_isactor = 1) lead, (SELECT people_id, people_fullname AS movie_director FROM people WHERE people_isdirector = 1) director, movie m WHERE m.movie_leadactor = lead.people_id AND m.movie_director = director.people_id; As you can see this query is pretty complicated, so let me explain it a bit. The first SELECT after the FROM is where we are getting the leadactor from, note we aliased the table "lead", but basically this just pulls id and the name of the actor as the leadactor, pretty simple so it is like we have a table called "lead" setup which has people_id, people_fullname pulled from people where isactor is set to 1. Pretty basic stuff there, the second query does much of the same, but only pulls the director. Now onto the WHERE clause, basically we take the movie table and join it to our "lead" and "director" table using the actor/director people_id. And then viola, we have our table like it was meant to be done. As to what you were doing wrong, well you needed to dig more into this, as it is not a simple query like some people would think it to be due to the simple fact that you have to pull 2 rows from a single table per query, which does require some unusual tactics. EDIT: I hope this was not a homework assignment.
  3. You need to use mysql_query instead, as $dbconnAC is not an object but a resource link to your MySQL connection. $dbconnAC = mysql_connect($sq_hst, $sq_unme, $sq_pzwrd) or trigger_error('Error, AC101: Transaction failed.'); mysql_select_db($database) or trigger_error('Error, AC102: Transaction failed.'); if(isset($_POST['queryString'])) { $queryString = $_POST['queryString']; if(strlen($queryString) >0) { $query = mysql_query("SELECT DISTINCT item FROM place WHERE item LIKE '$queryString%' LIMIT 10") or trigger_error("Query Failed: " . mysql_error()); if($query) { while ($result = $query ->fetch_object()) { echo '<li onclick="fill('.$result->value.');">'.$result->value.'</li>'; } } else { echo 'ERROR: There was a problem with the query.'; } } else { } } else { } mysql_close($dbconnAC);
  4. You see me helping here is kind of like a male stripper working for free. At first they wonder about you, then they see your package and fall in love instantly. It is a hazard of the trade I am afraid
  5. If it works, it is probably correct. As for doing it different, it looks fine to me as long as it works. The date difference expressed out how you want it is rarely an easy task to accomplish. If you want to compare you code to other functions you can find plenty via google.
  6. Are you sure that you instantiated the class $dbconnAC prior to calling this function? Without more code, I cannot help much further than to tell you that error means you did not instantiate the $dbconnAC class and is throwing that error because $dbconnAC is not a class object.
  7. Well some stupid things to test, A make sure that file is there, you can do a simple check with a test script using file_exists you can also print the current working directory to make sure you are where you think you are with getcwd Check those items and see if anything is going fishy etc, you may find out that the current directory is not where you expected it to be, if that is the case I would use the $_SERVER['DOCUMENT_ROOT'] to define my paths to include so they are the absolute locations and not relatives (will make it more precise etc).
  8. Sounds like the DB design is way flawed. Look into MySQL Distinct and or Group By.
  9. while ($row = mysql_fetch_array( $countryList )) { foreach ($row as $value) { echo '<option value = "' . $value . '">' . $value . '</option>'; } } I highly doubt that is what you want, I think you are after something like this instead: while ($row = mysql_fetch_array( $countryList )) { echo '<option value = "' . $row[0] . '">' . $row[0] . '</option>'; } Given that your table has the country name at $row[0], you should really define the columns you want out of the table in the MySQL select statement so you know what is at which index, it will also improve your MySQL performance.
  10. So you want it to search for this or this or this. If you do look at the tutorial there is coding in there on how to dynamically setup the query. But this is the gist of it: $array1 = array("dog", "muck", "fun"); if (is_array($array1)) { $search = "(column LIKE '%" . implode("%' OR column LIKE '%", $array1) . "%')"; echo $search; } Just replace column with what your column name actually is. If OR is not what you are after change it to AND.
  11. I do not understand this portion: for($i=0; $i < strlen($tag); $i++){ $this->tags = $tag."\n"; } Why are you using a for loop here and why are you writing it character by character? This would be much easier: $this->tags .= $tag."\n"; So your code should look like: function add_head($tag) { if(!empty($tag) && !stristr($this->tags, $tag)){ $this->tags .= $tag."\n"; } The reason for the .= is that is appending the new information to the end of $this->tags string, the way you had it before was overwriting the string each time, I am actually surprised it worked for the first item.
  12. By fixing the code, you sure can. We do not know what the potential problems are in the code and thus cannot provide much more information on how to secure your site without code.
  13. You have to structure the data for the query, do you want to find ALL data in the array or just some data? A good tutorial that may help you out is the Simple SQL Search Which explains how to set it up etc and will hopefully get you going on your way.
  14. Because html sucks? How does that suck, it was designed that way for a very good reason. If it was not then you would get a TON of new lines just from the code being on separate lines itself and if you were to only code new lines when text was involved, well that would be a mess of code and very hard to read.
  15. Because login is a column and if they are denoted they need to be denoted by back ticks ( ` ) and not single quotes ( ' ). Fixing that should get it to work (I tested a similar version on my server). INSERT INTO `gaming` (`login`) SELECT `login` FROM `users` WHERE `login` not in (SELECT `login` FROM `gaming`)
  16. This is bad syntax for Javascript/HTML: onclick='disChange('hidSupply');' As you are using single quotes inside of single quotes. Replace the below code in your code and it will fix your JS error: onclick=\"disChange('hidSupply');\"
  17. Not sure, but this thread may help you out: http://www.actionscript.org/forums/showthread.php3?t=5136
  18. Not that this is the problem, but you have a bad parameter sent with the visitor email: mail($visitormail, "Thank you for your interest in Jooma Properties", $responce, $headers, "From: support@bhawap.com"); I do not think that is valid, here is the corrected condition and hopefully that fixes the html portion of the email. mail($visitormail, "Thank you for your interest in Jooma Properties", $responce, $headers, "-fsupport@bhawap.com"); Would be the valid way to do that. If that does not work, perhaps your host has certain restrictions on it or try and use PEAR::Mail_Mime possibly. EDIT: Marcus beat me to the flag portion, but yea posting for the extra info.
  19. It depends on the format they are being pulled out of the database, either way you should be able to use strtotime along with the function found at the below webpage to calculate it: Google Results for php time difference Noteable sites: http://www.charles-reace.com/PHP_and_MySQL/Time_Difference/ http://www.gidnetwork.com/b-16.html
  20. You can use the IN() operator: UPDATE table_name SET col1 = somedata, col2 = somemoredata WHERE id IN(1, 2, 3, 4) Well only update col1 and col2 in the table where the ids are equal to 1 or 2 or 3 or 4
  21. No. As far as it not working, is Outlook Express setup to receive HTML emails? Or does it automatically convert them to text. Check your settings and see if that is the issue.
  22. Why remove the post? You should have replied with how you solved it to help others who may have a similar issue.
  23. "<div id='hidBook' style='display:" . ($ordBook=='1' ? 'block' : 'none') . ";'>" . You have to concatenate it since it is an operation that is taking place.
  24. Take a look at the mail() function in the PHP Manual and notably look at example #4. I believe you want to send the EMail as an HTML email. If not then disregard this and please elaborate on what you want as I am confused
  25. strpos You have your parameters mixed up: if (strpos($file, $value) === false) Will work like you want it to.
×
×
  • 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.