![]() |
Not sure if I'm following you?
php Code:
|
Thanks, I found this one which is very similar with yours, too.
PHP Code:
|
Exactly the same thing, I just didn't know if you wanted to grab the entire row or just the title. ;) If you are just grabbing the title, make sure your SQL query reflects as such!
|
Is there a reason you are storing the data then directly outputting it? I can't see a real reason to do that.
|
Because I want to use it in another file. In another file, I include this one and than I echo the mysql results.
|
Anyway to do this using function ?
|
Lots of different ways, it all depends on what you want the data to look like and what you plan on doing with it. Without knowing the purpose of the query/display, only you know the best way, all we can do is provide examples of methods to use.
php Code:
VI has a point though, if ALL you are doing is directly echo'ing the data to STDOUT, there's no reason to take up resources storing it. Just echo it. If you need to perform operations on the data first, then echo it, store it in an array. |
Thanks, but I can't make it a function like you said, can you help me ?
PHP Code:
|
I don't think we're making any headway here. You're making the whole process a lot more difficult than it needs to be, and that's probably partially my fault for the original example.
php Code:
|
I have a file which is named mysql.php, I want to make a function in this file and than in another file which is search.php, I include mysql.php and than use the function to get mysql results. Thanks...
|
|
Thanks anyway...
|
I'm not sure how to help you from here without writing it for you - any block of code can be turned into a function to do this. If you're including the file, it doesn't necessarily even need to be a function, unless of course it's a library of functions meant for a variety of purposes, which is usually the concept behind having a seperate file inclusion.
The above link illustrates how to form a user defined function. You place the code inside the function, include the file, and call the function. |
Not knowing how to do something is quite usual for a programmer, it is a needed trait of any good programmer to be able to work from what they have and get the job done. Break what you need to do down and work it out from there. Google is your friend for each little step. If you can't do that, there is no real help that we can give you. Sorry if this comes across as insulting, but you do not appear to even be attempting to think on your feet here.
|
| All times are GMT. The time now is 09:55 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0