hey guys, this is my first post in here - i'm also a member of php and flashdev
this seems simple, but i hope i don't bungle it up - i don't have a concrete example for this, just something i've been thinking about
let's say i have 2 tables, categories and items and there exists items.categoryID and category.ID;
is there an easy way to select only the categories that have associated items?
for instance:
if i have: categories ---------- 1. Category A 2. Category B 3. Category C 4. Category D (1, 2, 3 and 4 being categories.id)
and
items ----- 1. Item A (items.categoryID = 1) 2. Item B (items.categoryID = 4)
can I, with just 1 select query, pull ONLY Category A (id = 1) and Category D (id = 4) to say, build a menu of categories, selecting only those categories that are "populated"?
in the past, how i've done this has been select ALL categories, then one at a time loop through the categories and do a SELECT statement for each ID and check for at least 1 result; then flag each category that has associated "stuff"; this is allright if the page you're building has to list all the products AND categories, but let's say I just want to build a menu of only available categories and not display any items (or not ALL the items) on a given page
any help is appreciated; let me know if that makes any sense...
hello. i'm new here. kind of new with webdesign as well (been doing it for almost a year just as a hobby; mostly with css and html).
1. i'm just curious as to how many of you actually have made webdesign/programming your career, and if so, what route did you take in college (certificate, associates, bachelors, etc). i'm a second year community college student, and i'm interested in persuing webdesign as a career, technical side and design side, so i guess im just confused as to what i should do in school to get where i'm wanting to be (job as a webdesigner for a company). any tips, suggestions?
2.also, i'm sure this has been asked a million times before, but in the userinfo, " Affordable & Reliable Webhosts" was left blank. so i'm going to ask you guys for some reccomendations on hosts. ive done godaddy, and 1and1.com before.. and neither have what i want for a low enough price. i'm looking for something that will allow me to have multiple ftp accounts, php, a decent amount of bandwidth, multiple domain hosting, etc. any suggestions?
3. last but not least, i'm looking into using moveable type as a blog for my website. i would like to achieve something like this. does anyone have any experience with this? is it fairly easy? is there something better i should be using. as you can tell, i'm kind of a beginner, and i would love if you would point me in the right direction if i'm missing out on something better.
I know that some things are faster in PHP then others, like echo and print for example off my head. As every like is like that of course. Though there is also bit functionality different from them too but, factor of common use of them is the same. Anyhow, if's are pretty much based on freedom choice, meaning there is so much you can do with them and I want to know which is most fastest by server.
I finally got around to re-installing Norton Anti-Virus, after over a year without it. Of course, it was too late. I did a scan, and a lot of viruses weren't able to be deleted. Also, I keep getting a virus alert for W32.Desktophijack and Trojan.Desktophijack.B it says Unable to repair this file and Access to the file was denied. So how do I go about getting rid of those? And also, here's a list of the things that failed to delete from the scan: -1.exe msbb321.dll msiaih.dll msnimk.gif P2P-p2p-10460.exe quykw.dat redit.cpl supdate.dll tool4_b2seach.exe
And just incase... Logfile of HijackThis v1.99.1 Scan saved at 2:00:42 PM, on 7/9/2005 Platform: Windows XP (WinNT 5.01.2600) MSIE: Internet Explorer v6.00 (6.00.2600.0000)
To test things, I've created a file in the root of my server called phpinfo.php. In it, I'm calling PHP's phpinfo() function. If I call the file with its extension, I get the expected results. However, if I call the file without its extension, I get a prompt to download a file of type appliation/x-httpd-php named phpinfo.
Here is the relevant section of /etc/apache2/sites-enabled/000-default (which is a link to /etc/apache2/sites-available/default):
DocumentRoot /var/www/
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
RedirectMatch ^/$ /apache2-default/
I have the information for parsing PHP in /etc/apache2/apache2.conf (actually, it was already there; I merely had to uncomment it):
The reasoning behind using MultiViews right now instead of type-maps is because I don't want to have to define type-maps for every single file/resource I'm going to provide. If a type-map doesn't exist for a resource, content negotiation will fall back to MultiViews.
Am I missing something? Obviously, I am. Why am I being prompted to download the file? Why isn't the file being parsed by the server, like I'm telling it to?
NOTE: I had content negotiation working with Apache 1.3. It was only when I upgraded to Apache 2 that it stopped working as expected.
Quick question. I'm trying to create something akin to a deck of cards, where an item is removed from an array through a random value. This stops being a factor in future selections until it is repopulated.
The problem is that after scouring my PHP manual, I can't see a thing about this specifically. I probably missed something, which is why I want to see if there are options that you are aware of.
How would one go about determining a file's MIME type with PHP?
I've seen a few solutions that all involve maintaining a discrete list somewhere and updating it--in addition to any other local MIME type lists--as needed. I'd rather use a less "clumsy" way of doing this if one exists.
EDIT: Nevermind! The function was hiding on me on php.net: mime_content_type. I realize that this has been deprecated by the PECL fileinfo extension, but it works for me for now.
I've dabbled in building a small site or two with PHP, but my friend has asked me to help with a large scope project. It'll be a site that helps companies stay in touch with clients, posting progress reports on the web. (There are a few sites that already provide this service, but we're looking to start this ourselves, if only for the learning experience.)
Conceptually, I have no problem with most of the project, but it just seems like too much coding to get done in a reasonable time-frame. Surely there are some template code-blocks out there for things like: creating user-accounts with passwords & password hints; file upload scripts that check whether filetypes and sizes are valid; juggling filetypes between pdf's and images; etc.
Do sites with templates for this exist, or is this just wishful thinking on my part?
I need some help with a query I'm trying to create to send to MySQL. The problems are on the PHP side, so I'm posting here rather than at mysql.
I have an array of starting letters. I'm trying to select all projects that start with a letter in an array. The array will have at least one letter, possibly more.
Here is the code that's causing me confusion:
foreach ($startlet as $let){
$sql.=" $projectcolumn[title] LIKE '".$let."%'";
}
I need to put an OR in there at the end of every line but the last. Is there an easy way to do this, or am I going to need to get the length of the array, then iterate some number and compare? I'm fine with a different control structure, but I couldn't find anything that would easily and simply do what I want. Is there one, or am I just going to have to be satisfied with complex? Edit: Never mind Figured I could do it this way. Maybe not so pretty, but functional.
$i=0;
while ($i<(count($startlet)-1)){
$sql.=" $projectcolumn[title] LIKE '".$startlet[$i]."%' OR";
$i++;
}
$sql.=" $projectcolumn[title] LIKE '".$startlet[$i]."%'";
Is there a way to use javascript to select one or more of the options? That is, to hightlight them as if the user clicked on them with the mouse.
The name of the box has to have a [] on the end, since I'm passing this to PHP, and it's gotta be named like an array in order to pass all of the information (which options the user has selected.)
document.addPost.relatedFiles[0].options[0].selected doesn't work, neither does document.addPost.relatedFiles.options[0].selected.
This is driving me crazy. Any help would be much, much appreciated.
I'm redoing the site template for this intranet website I'm designing - the Dreamweaver template I'd made using tables is completely, inexplicably fubar on certain pages of the site. I got sick of messing with it and told my boss I was going to make an all-new, CSS-based layout, and that was that. He agreed to let me do so.
Everything's been going fine...I've been doing my primary testing in FireFox, but I've been doing testing in IE6 (mostly because that's what almost everyone in this department is likely to use), as well as minimal viewing in Opera 8 and Netscape 7.
Suddenly, things broke. Now I have part of the content text repeated below my footer text. See link here:
I've discovered that if I remove the "float: left" property of the lefthand area of the site in my CSS, it fixes it. However (of course), removing that element completely throws the site layout out of whack. I'm about to do absolute positioning of all the elements and throw this template out the window.
I beseech you, please, please help me.
Oh, and while I'm at it...I want the gray lefthand column to extend to the bottom of the browser window, regardless of the length of the content. In all browsers, setting the "length" property to "100%" makes it too long, because there's stuff ABOVE that navigation bar. Any ideas?
Whenever I've got a mysql query and the user is inputting something in a feild (let's just say for example a login page), I add addslashes to every GET and POST request. Is there anything else I can do to protect myself from sql injection? I'm fairly new to mysql so I'm not entirely sure of all of its commands and what not. I thought it would be appropriate to post this in a PHP community, though, because everything that I would have to worry about is in my php coding.
I'm writting this more in a inquisitive mode. I'm designing my URIs for my site, and i was just wondering what was your take on this subject. Bear in mind that this is for a blog... archive and stuff.
A few start-up points.
Why use http://host/post/1 instead of the usual http://host/file.php?page=post.php+id=1? to be search-engines-friendly, and it looks normal for "the common folk", it looks tidier ;) and plus, enables you to change the way your site works without breaking your links... are there more reasons?
The usage of id's or a slug for posts? what's best? With id's you win in length, but you loose in quick identification of the post.. points for and against?
When an archive, use date, for instance: http://host/2005/07/03/slug you automatically sort your posts under year and month.. but is it really necessary to include the day?
what else? i'd like to hear your views...
Sorry if this has been discussed already.. if so, let me know and i'll remove this.
Today I had an interesting conversation with my ex-Boss and good friend. He asked me to summarize the current state of Java world these days as he was busy with databases and scientific computing. Here is my short take on it.
Ruby has become a cult like Apple.
PHP guys think they are winning over Java. [...]
Hello everyone! I'm at a real loss with this website I'm developing. You might remember I posted about making an enrollment form, and you were all super helpful. The thing is that the server hosting the site does not support any scripting, so I've had to code the page the retard way (http://www.cfs.purdue.edu/itsi/testitems/EnrollmentForm1.htm). The people want there to be at least a confirmation page show when the person submits the e-mail, which I have included. However, the page shows up if the user presses submit, regardless of whether or not it has submitted, and in a new window. This is just done using Dreamweaver options to open a browser window upon submit.
Can anyone take a look at it and tell me what in the world I can do for these folks? I've looked online, everyone says PHP, scripts... I'm going nowhere on it.
Has anyone successfully upgraded the version of PHP that comes preinstalled with Tiger to PHP5? I tried using darwin ports (sudo port install php5) and it says it's activated, but when I run php -r "phpinfo();" it still says its using php 4. So I'm thinking I'm gonna have to compile it from source, unless there's a better way. Any suggestions?
I know, another "what CMS should I use?" question. But hear me out. I'm looking for a CMS that's flexible, easy to set up, allows all users to submit content, and has some sort of mechanism for reviewing items (like Epinions or Amazon or Yelp.)
I can run PHP (safe mode only) or Perl, and I've got a MySQL database.