
artacus
Members-
Posts
737 -
Joined
-
Last visited
Never
Everything posted by artacus
-
I assumed you meant "get THE number of rows", in which case it is VERY inefficient. It has to select every row from the table and return it. So in that situation COUNT(*) would be a huge performance gain. Now the second time around, you show me a query that probably returns one or two rows. In that case it really wont make much of a difference, especially since you are probably going to want to know who they are.
-
Can you be more vague please? Do you get an error, whats the error message? Use "FROM sales AS s" instead of "FROM sales=s" Also, while left join and right join do pretty much the same thing, Left join is pretty much the industry convention.
-
Retrieving,Sorting & Displaying Multiple Results from Mutliple Tables
artacus replied to Andrius's topic in PHP Coding Help
Ok, you're making it way harder than it needs to be. First, try using mysql_fetch_assoc() or mysql_fetch_array() Second, try to do all your php stuff in one location if you can instead of interspersing it w/ html Make your db calls like so: //get feature_header $query = "SELECT * FROM header_feature ORDER BY RAND() LIMIT 1"; $result = mysql_query($query) or die(mysql_error()); $header_row = mysql_fetch_assoc($result); //get header $query = "SELECT * FROM feature ORDER BY RAND() LIMIT 1"; $result = mysql_query($query) or die(mysql_error()); $feature_row = mysql_fetch_assoc($result); $feature_img = "<img src='Images/$feature_row[image]' border='1' /> "; $query = "SELECT * FROM news ORDER BY `Date` DESC LIMIT 6"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { $news_disp .= "\n\t<tr><td>$row[title]</td>..."; } When you get to the point in your html where you want to display the stuff you've built in php, just echo it out <table> <?=$news_disp ?> </table> -
SELECT COUNT(*) FROM hugeTable
-
You have conflicting WHERE clauses... note date CANT be between that range when it doesn't exist. Also, note.id is not going to be the FK relating to account.id SELECT a.name, a.phone_office FROM accounts AS a LEFT JOIN notes AS n ON as.id = n.account_id AND n.date_created > DATE_SUB(NOW(),INTERVAL 6 MONTH) WHERE n.id IS NULL;
-
Retrieving,Sorting & Displaying Multiple Results from Mutliple Tables
artacus replied to Andrius's topic in PHP Coding Help
Why don't you post a specific question that you are having trouble with then instead of giving me 300 lines of code to read thru. -
Hint: Date is a reserved word... one that everyone likes to use as a column name
-
Yeah I missed the var assignment the first time thru. file_get_contents works for this huh? You are a genius.
-
LOL. So now that everyone has had a chance to weigh in on the subject, how do you change the darn field?
-
That will only work if he wants to display that page. Its not going to work if he wants to return it as a variable and parse thru it. $dogggg = include ("$SpecialString"); returns 1 meaning it succeeded. It's NOT the text from the page. If it's a page that you have control over (I doubt it), you can make it's contents read something like <?php $doggg = "...whatever..."; Otherwise use curl.
-
For the love of Ober! Why does every n00b have the insatiable desire to do this? I don't understand it. We get this question about once a week. Its still a bad idea this week. Feel free to check back next week and see if it makes sense then. Seriously though. This isn't what PK's are for. If you feel the need to store this info (it should be calculated on the fly), add another column like 'sort_order' and use that.
-
curl is what you want.
-
Retrieving,Sorting & Displaying Multiple Results from Mutliple Tables
artacus replied to Andrius's topic in PHP Coding Help
Leave the snide comments to me please. I'm a trained professional. Actually you SHOULD rename the "Date" field IN "News" because that's a reserved word. Ok, so the way you phrased your subject made it sound like you wanted to join these tables some how. And I was trying to figure out why. So you'd probably pull the header_feature and feature rows first. Get a random row like so: SELECT * FROM header_feature ORDER BY RAND() LIMIT 1 Fenway has some ideas how to do this more efficiently in the mysql forum. To pull the most recent articles SELECT * FROM news ORDER BY `Date` DESC LIMIT 6 -
Works fine on my server, but does not work on customers
artacus replied to cnl83's topic in PHP Coding Help
First make sure that uploads dir is writable by your apache user. You can eliminate a lot of your complexity by using relative file names. You do this: //Change scope of file var $file = $_FILES['file']; But I don't see you reference $file anywhere and $_FILES is global anyhow so there's no need. -
Retrieving,Sorting & Displaying Multiple Results from Mutliple Tables
artacus replied to Andrius's topic in PHP Coding Help
That makes the left cheek of my smart ass tingle Ok, what I dont understand is why you would have a Feature and Header_feature table. It doesn't see like you would need them because you are just pulling the 6 most recent articles. -
Just do it when you are pulling it from the database SELECT DATE_ADD(myDate, INTERVAL 1 DAY) AS newDay
-
Oh, and I forgot to slap you for not making sure your data was backed up. *slap*
-
http://forums.mysql.com/read.php?22,47078,51428#msg-51428
-
Sounds like you would be fine either way. MyISAM will be faster for you. So on a system with limited resources, I'd stick with that unless there was a compelling reason to use InnoDB
-
You're right. But seeing as how Timbo actually figured it out on his own instead of asking "So what's a subquery? Can you write it for me?" [red]I[/red] wasn't going to crush his spirit.
-
Yeah, thats 1 query for the outer and n for the inner
-
Without really having a clue what you're doing. I'd strongly recommend something like so: Servicedesk -- service_id INT AUTOINC -- batch INT -- promo INT -- ens INT Status -- service_id INT -- frm DECIMAL(5,2) -- odw DECIMAL (5,2)
-
It is. What Fenway is saying is that since you are looking up all your users anyway, do the subquery in the FROM section so you can do two queries instead of n+1 queries in the WHERE clause.
-
I'm not entirely sure that it makes sense to do this... But, first make sure that the field is long enough to store the longer hash. I believe it is 40 characters now, look it up to be sure. Look it up using: AND (PASSWORD('$pass') OR OLD_PASSWORD('$pass')) return the hashed password in your query and if its length is less than 40, update it using $pass that the user provided.
-
LOL. That and the summer internship I did with the psychic friends network REALLY comes in handy. Lucky for us, fiber optic cable channels psychic energy even better than copper. Wonder how old Dion is doing, haven't seen her in a while.