Jump to content
Larry Ullman's Book Forums

Jonathon

Members
  • Posts

    1064
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Jonathon

  1. This line should be $con = mysqli_connect('stuff', 'stuff','stuff'); // connect to database
  2. hello wframe, $q = 'SELECT column_a, column_b FROM table'; $r = mysqli_query($dbc, $q); while (list($column_a, $column_ = mysqli_fetch_array($r, MYSQLI_NUM)) { // Do something with the listed variables } // End of while loop Is a way to assign mysql results and put them straight into a variable to use later on Hope that helps? Jonathon
  3. Yes i'd agree, it would really be an interactive way to learn, which would appeal to many! I'm sure Amazon does provide a massive market for possible buyers. But, with the kind of figures you told me you were receiveing through your site each month, you've got a very keen audience here. But if I want a book/kindle(if I had one), i'd go Amazon and I suppose most others would too, I suspect many like me, have bought a book of yours and then looked at other books of yours they could buy to increase their knowledge. On the other hand, I'm sure you put a lot of money through Amazon, so maybe you could negotiate a better deal?!(Then write a book about "tackling Amazon" ) Perhaps I'm getting ahead of myself here but, (bear with me, because it ultimately means more work for you)! if you were to make an app for the JS book. Perhaps you could document your experiences and make that into another self-published book. I can only see the app market going up and up currently, and everyone wants to cash in on it. So at this time it could be quite the investment. But I imagine it would cost you a LOT of time (one would imagine).
  4. Haha, "Good things come to those who wait"! So i'm told anyway. Format wise, thats a toughy! For me I love having a printed version, So I can scribble my notes down as I go through. But I would imagine the cost of that format would be a lot more than other formats. You can't really go wrong with a PDF i'd say, for both the consumer and the manurfacturer. Because everyones got a device that can utilise a PDF readily (Mac/PC/iPad..etc) and they can then print this if they wanted too. I havent used a kindle or ePub though i'm sure theyr'e both excellent products. But i'm unsure of the costs involved with any of these formats. I just imagine PDF would be the more universal platform. What are your thoughts? I'm sure the apps would go down very well indeed too!
  5. Yeah, I'll definately be purchasing the JS book, so I hope it does work out for you and it opens up the possiblities of being able to write whatever you want.
  6. Yeah I agree. I love MySQL but I have seen people who use other databases and thought, maybe I should get acquainted with a 'backup' or alternative. Maybe you could self-publish a PostgreSQL book. (If you get a chance)
  7. Yeah I know. Although its bad publicity, I'm not sure how many would jump ship so to speak. But saying that you'd feel different if it was sure site that got hacked.
  8. Hi Shaneg, I'm still not 100% sure of what you want to achieve. But i get the general idea. To be honest unless you have a very complex script the difference in performance it will take to execute will be negligible. If you want to, see the end of this topic I started. Programming speeds
  9. This is my file for your reference and this works. also note the variable $canada in your script is miss-splet <!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 content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Untitled 1</title> </head> <body> <?php // Create one array $mexico = array( 'YU' => 'Yucatan', 'BC' => 'Baja California', 'OA' => 'Oaxaca' ); // Create another array $us = array( 'MD' => 'Maryland', 'IL' => 'Illinois', 'PA' => 'Pensilvania', 'IA' => 'Iowa' ); // Create another array $canada = array( 'QC' => 'Quebec', 'AB' => 'Alberta', 'NT' => 'Northwest Territories', 'YT' => 'Yukon', 'PE' => 'Prince Edward Island' ); // Combine arrays $n_america = array( 'Mexico' => $mexico, 'Canada' => $canada, 'United States' => $us ); // Loop through the countries foreach ($n_america as $country => $list) { // Print heading echo "<h2>$country</h2><ul>"; // Print each state or province foreach ($list as $key => $value) { echo "<li>$key - $value</li>\n"; } // Close List echo '</ul>'; } // End of main foreach ?> </body> </html>
  10. Your also missing the opening brace here: // Loop through the countries foreach ($n_america as $country => $list) { // missing brace and the subsequent closing one after the last echo
  11. Glad you sorted it Jeff. For reference if you get stuck its probably best to post your code so people can have a look if there's something wrong in it. Though probably best you *** out your connection details.
  12. Hi Jeff, It looks like your trying to include the constant again. If you post the code that your including the mysqli file it might show us where the problem is.
  13. <!-- this in html is a comment--> much like // this is a comment in php
  14. Hi Chris, If you post your code we'll be able to see if theres anything wrong with it. Otherwise i'm afraid it's pure guess work
  15. Hi Jeff You can either use an absoulte path which is the full path to the file or a relative one like "../folder/connect.php" to access files in a folder above where the script is executed.
  16. Yeah that seems like the way i'd go, using the RegEx to grab the data and then parse insde that. I don't have too much to do with RegExs so my experiences with them aren't vast. But I get by!
  17. What are you capturing them for?? I think you can parse it XML using the parent node (thought not sure)
  18. Right, looking at the second query that is erroring. The code should start something more like this: $q1 = 'SELECT xacres01 FROM xacres WHERE user_id=.............. I don't know your table or globals so I cant comment if they are right. Then, run the query $r1 = mysqli_query($dbc, $q1); if (mysqli_num_rows($r) == 1) { // IF The result returned 1 array that is if you mean it to return just 1 array list($owned) = mysqli_fetch_array($r, MYSQLI_NUM) } else { echo 'error with num rows'; } This will return a variable called $owned that should have the `xacres01` column in it. From there use the $owned variable inside the next MySQL query ($q2). something like "SELECT `column` FROM `table` where owned='$owned'"; I haven't run this code from an editor, so just make sure i haven't omitted any ';' or other syntax. Jonathon
  19. I'm currently in work and on my phone. But I shall look at this in more depth when I'm in. It seems to me that: 1 - rather than use * just select the column you need from each table. 2 - use mysql to return the array and list() the value from the column in xacres table. Basically you assign value from the DB straight a variable. 3 - do any validation you need to do I.e. You got a valid result from the query and run the second query, using the $var you got from using the list() function on the first query results. Although I am still a bit confused as to what your trying to achieve, is this what you want to happen? 1 - Select 1 `column` from `xacres` table save the result as a variable 2 - Then use this variable inside the next MySQL query to get obtain the desired result. Also do you expect the query to return 1 result if so then you don't need a LIMIT. If it's going to return more than 1 result then how do you know which result you actually need.
  20. To be honest if i'd spent the time and effort to find out that '' is ONLY 0.26% faster than "", i'd be pretty upset.
×
×
  • Create New...