-
Posts
4,362 -
Joined
-
Last visited
-
Days Won
11
Everything posted by Zane
-
A screenshot would be helpful.. or a link to the actual site of this problem. Otherwise, we will have to create our own HTML to go along with your CSS.. and that could take quite some time.
-
$query ["SELECT * FROM shoe WHERE itemcode LIKE '%".$itemcode."%' "] or die(mysql_error()) You are missing the equals sign. Also, why do you have this in square brackets? This part while ($i < $num) { $itemcode=mysql_result($result,$i,"itemcode"); $itemdesc=mysql_result($result,$i,"itemdesc"); $color=mysql_result($result,$i,"color"); $size=mysql_result($result,$i,"size"); $price=mysql_result($result,$i,"price"); $qty=mysql_result($result,$i,"qty"); $i++; } ....is better off like this while ($r = mysql_fetch_assoc($result)) { $itemcode=$r['itemcode']; ... ... ... ... } And finally,. your code will only display ONE result, which will be the very last one in your $result. The displaying HTML needs to be within the while loop
-
Could you elaborate a bit more? AKA, put more effort into your question?
-
Yea, you would need a better condition than ready()... like txtbox1.change() or something
-
Do you use includes or a Table for data driven apps
Zane replied to phpjim's topic in PHP Coding Help
What exactly do you mean by storing those items in a table? If you are talking about a database table then that is just outright illogical. You would need to be authenticated in the first place to access that table. To answer your second question, Yes. Pretty much any server-side language will be able to store session data as well as create cookies. PHP offers $_SERVER variables as a means to get the information of the user. Data such as the user's IP, browser name, referring page, operating system, etcetera are all available in the $_SERVER superglobal. While this variable is not readonly, it is useless to store data in since each page refresh will, AFAIK, generate a rebooted array of values. PHP is a very very well documented language, it is even safe to say that it is the BEST documented language. Take a look through it if you haven't already. -
Cisz, you have failed to even mention the exact problem you are having. You pretty much just regurgitated your code out to us and said "It doesn't work." As you can see by the number of replies you surprisingly have already, this community wants to help you, but they cannot do so effectively if you do not ask your question effectively. Are you positive that your file uploaded correctly? If you are not sure, then check through FTP or whatever means you use to view your files.... if it is there, then you're problem may be that you are giving the wrong path. We need to know things like, your directory structure and whether or not the upload actually works....etcetera... details.
-
you are MUCH MUCH better off using PHP's DOMDocument class. Scraping information like that is sooo much easier and it is also easier to fix whenever that site changes something in their code. Google DOMDocument and you should receive everything you need.
-
The real solution to your question is the syntax of the mysql_result function. Sure, I agree that you should not nest mysql functions, but your code should still work regardless and I'm not gonng preach to you about "ideal coding practices". The number one step in figuring anything out in PHP is to look at it's very elaborately awesome manual. You are currently using this code mysql_result(mysql_query($query), 0, 0); If you were to look at the manual for mysql_result you would realize you should be using this syntax. mysql_result(mysql_query($query), 0); Why? because your query only selects ONE field. There is no point in specifying the third argument when you only have one field. It is optional If you did want to specify the third argument, it would be easier to use the fieldname mysql_result(mysql_query($query), 0, "thefieldname"); Theoretically, your use of the function should work, which says "mysql_result, first row, first column". I don't have an answer for why that isn't working as expected but I know that using the fieldname will fix it.
- 10 replies
-
- mysql
- single value
-
(and 2 more)
Tagged with:
-
Efficient way to display multiple fields of MySQL table into a webpage
Zane replied to Jagand's topic in Application Design
I am participating in this question mainly because I too am interested. I like the idea of having a XML/JSON file created. What I wonder though, what would be the method with the most integrity, etcetera. My idea is that you could create a new JSON file per session. If the user uses the search bar more than one, the JSON file is just overwritten since the file would be named using their session_id(). Then, somehow I would need to delete all of these files systematically. It seems a chrontab could do this the best?. I am moving this to Application Design btw. -
The first year's round.
-
A better idea would be to add the extra view in your SQL update query UPDATE videos SET views = views + 1 WHERE ..... ...NOTE.. and yes, there is no $view variable in that query. All that query will do is increment the views field by one.
-
Yes you do. Except for the last part. You do not have to end the session. Sessions end when the browser is shut down.
-
Trouble moving files to directory selected in form.
Zane replied to strago's topic in PHP Coding Help
directory does not come from a file-input field. It should be $_POST['directory'] -
http://stackoverflow.com/a/3488430
-
Sign up for Google Analytics, it provides WAY more information that you could imagine.
-
The question has been answered yet the OP has been offended.. there's no point in keeping this thread open. Although I will agree with Jessica in the pointing out of whining. This is the internet, please try not to take people too seriously and as for the others... watch your words when you know damn well it could set someone off and destroy a thread.
-
How Do I Insert An Attribute Into A Specific Element?
Zane replied to Fluoresce's topic in PHP Coding Help
Something like this should do the trick. <ul> <li><a<?php echo isset($_GET['id'] && $_GET['id'] == 1) ? " class='active'" : "";?> href="page.php?id=1">Lorem Ipsum</a></li> <li><a<?php echo isset($_GET['id'] && $_GET['id'] == 2) ? " class='active'" : "";?> href="page.php?id=2">Lorem Ipsum</a></li> <li><a<?php echo isset($_GET['id'] && $_GET['id'] == 3) ? " class='active'" : "";?> href="page.php?id=3">Lorem Ipsum</a></li> <li><a<?php echo isset($_GET['id'] && $_GET['id'] == 4) ? " class='active'" : "";?> href="page.php?id=4">Lorem Ipsum</a></li> </ul> -
Maybe I'm just reading your question wrong or maybe it is just too early in the morning, but I cannot seem to grasp the logic of what you want to accomplish. From what I understand, the letter a would represent 10? The number 36 would be represented by z? Afterthat I get completely lost? What exactly would 3A represent? or 1A, 1G, etc.. It would help if you could elaborate more on what certain numbers would be represented by.
-
Congrats yo..
-
Object Oriented Programming Or Traditional Coding?
Zane replied to mostafatalebi's topic in PHP Coding Help
You are right. It is the fault of the teacher and the ignorance of the average American student. -
Object Oriented Programming Or Traditional Coding?
Zane replied to mostafatalebi's topic in PHP Coding Help
These seem to be the dumbest arguments since the Obama/Romney campaigns. Either side claims that their way will change the future and that that of the other side will destroy everything as we know it. I have yet to read an intelligent opinion on this case. Furthermore, this argument has came up several times in the past here. If no one can come up with a decent "argument" for the pros and cons of OOP, the thread will eventually and inevitably end up in a flame war at which point it will be locked. Someone put some effort into their arguments, provide some benchmarks, create some graphs, anotate a bibliography. Do anything other than just sling insults back and forth. ---------------------------------------------------------------------------------- Just for the record and to add my input, I have never used OOP in a professional setting, only in the classroom. I must say, OOP does have its advantages. It keeps you from rewriting code, it allows you to use it over and over again, and given the proper nomenclature... Objects serve as a simple way to accomplish something that would normally be rather difficult. What I do not like about OOP is that it advocates copy and pasting. When I was in my C# class, the teacher would give us the code to connect to a database. All of the students heavily relied on Copying and Pasting because throughout the semester we migrated from procedural code in the beginning and converted it into OOP in the end. I will bet you anything though that none of those students actually know how to connect to a database today without looking through their old flash drives. We were taught the use of Objects and that the ConnectionObject allowed us to create a connection to the database. Several other Objects allowed us to retrieve and store that information. We never had to write this code manually though. It was provided for us and 99% of the class, including me, could care less how those Connection and Fetching Objects worked since we had them in our own classes and methods. It wasn't until I started having to debug errors that I realized the fallacy of OOP. If you simply copy and paste a bunch of code snippets you find out in wherever into a method named something like.. findNearestByZip, then when the code within that method fails you have no idea why. You are left with the options of tackling it yourself, googling the error, posting in a forum or searching for a new algorithm altogether because you have no idea what you have copied and pasted. -
You're better off doing this through the SQL query SELECT * FROM ips WHERE ip = '$getip'
-
If you plan to carry variables over multiple pages, your best option is to use SESSIONs which were made specifically for that reason. Read up on Sessions in the PHP Manual, they are very easy to use given you read the instructions. Just a quick hint for your future questions.. You will have to store POST or GET data into these SESSIONS. That is how you will accomplish what you are trying to do.
-
A much better approach to this would be to use an array instead of having a billion ifs and if elses.. if(trim($name) == '') $error[] = '<div class="errormsg">Please enter your name!'; if(trim($email) == '') $error[] = '<div class="errormsg">Please enter your email address!</div>'; if(!isEmail($email)) $error[] = '<div class="errormsg">You have enter an invalid e-mail address. Please, try again!</div>'; if(trim($subject) == '') $error[] = '<div class="errormsg">Please enter a subject!</div>'; //etcetera etcetera.. Then you can use the implode function in the end to echo them...as well as check for errors. if(count($error) != 0) echo implode("\n", $errors); else { Execute code for success.... }