php-general Digest 9 Oct 2012 19:18:18 -0000 Issue 7999
Topics (messages 319389 through 319391):
Re: limiting
319389 by: Matijn Woudt
319390 by: Jim Giner
319391 by: David McGlone
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Tue, Oct 9, 2012 at 8:30 AM, ma...@behnke.biz <ma...@behnke.biz> wrote:
>
>
> David McGlone <da...@dmcentral.net> hat am 9. Oktober 2012 um 05:11
> geschrieben:
>> Hi all,
>>
>> is there any other way to limit this code to only displaying 1 image other
>> than using return. When I use return, I can't get the other images to display
>> in lightbox, but when I use echo, all 5 of the images will correctly display
>> in lightbox, but they are also displaying on the page.
>>
>> $result = mysql_query("SELECT * FROM properties");
>> $row = mysql_fetch_array($result);
>> $matches = glob('images/property_pics/212006966/' .$prefix. '*');
>> foreach($matches as $match){
>> echo "<a href=$match rel='lightbox[$matches]' /><img src =
>> $match></a>";
>>
>> I'm not even sure if this is possible, but thought I'd ask before I scrapped
>> the idea. I've been at this code since last thursday trying to learn as much
>> as I can about it and I just keep going in circles and I'm starting to feel
>> like glob() is what is limiting me. I've tried various code blocks with
>> things
>> like where(), str_repeat, basename, scandir, sort etc with no luck. :-/
>>
>
> This is less a PHP question but more a question about your html and javascript
> code.
> Please supply as bit more information about your page and were which images
> should go.
>
> Without seeing what you are doing I would think that you must collect the
> images
> in an array that is used to print out the images on the page at two different
> locations. Something like:
>
> $result = mysql_query("SELECT * FROM properties");
> $row = mysql_fetch_array($result);
> $matches = glob('images/property_pics/212006966/' .$prefix. '*');
> $images = array();
> foreach ($matches as $match) {
> $images[] = "<a href='$match' rel='lightbox[$matches]' /><img src
> ='$match'></a>";
> }
>
> // print only first image
> echo $image[0];
>
> // print all images
> foreach ($images as $image) {
> echo $image;
> }
>
>
Or simply
$result = mysql_query("SELECT * FROM properties");
$row = mysql_fetch_array($result);
$matches = glob('images/property_pics/212006966/' .$prefix. '*');
echo "<a href=".$matches[0]." rel='lightbox[$matches]' /><img src =
".$matches[0]."></a>";
though rel='lightbox[$matches]' doesn't make sense, and you should use
quotes around the href and src tags.
- Matijn
--- End Message ---
--- Begin Message ---
On 10/8/2012 11:11 PM, David McGlone wrote:
Hi all,
is there any other way to limit this code to only displaying 1 image other
than using return. When I use return, I can't get the other images to display
in lightbox, but when I use echo, all 5 of the images will correctly display
in lightbox, but they are also displaying on the page.
$result = mysql_query("SELECT * FROM properties");
$row = mysql_fetch_array($result);
$matches = glob('images/property_pics/212006966/' .$prefix. '*');
foreach($matches as $match){
echo "<a href=$match rel='lightbox[$matches]' /><img src =
$match></a>";
I'm not even sure if this is possible, but thought I'd ask before I scrapped
the idea. I've been at this code since last thursday trying to learn as much
as I can about it and I just keep going in circles and I'm starting to feel
like glob() is what is limiting me. I've tried various code blocks with things
like where(), str_repeat, basename, scandir, sort etc with no luck. :-/
I hate to sound condescending, but you are showing some serious
deficiencies in your programming ability. I have to say that you are
tackling some very complex processes without the basic understanding of
programming that one needs. What I base this opinion on is that since
you first revealed your lack of understanding of Return and echo in php,
you have spent another 3 days and STILL don't understand? Really?
As for the code above - once again it looks like you have posted a
re-typing of some code you have tried to execute. I say that because
you have a query and a fetch of one record of the results THAT HAS
NOTHING TO DO WITH THE REST OF THE CODE! Also - you have an array
being used as part of the Rel tag? What's up with that? (I think you
meant to use $match - but that further verifies that this is NOT the
code you ran.)
Finally - the code is (from your description) doing exactly what it is
designed to do (the running code that is). All the (repeated) "echo"
statements are going to put something on your web page. The question
you have is (apparently) how to hide them, since I believe Lightbox is
going to have to have them present in order to do its thing. And so -
in parting - I think you need to develop some html knowledge to
facilitate that "hiding" part and some immediate skills in the general
area of programming and learning to locate and read the right manuals.
"Glob" is the least of your concerns.
Yes - I'm being rough (I say this to you David as well as the rest of
the community that is still interested in this post) but somebody has to
make you realize that you are seriously in over your head and don't even
know it. Have you read a book on php and perhaps one on CSS to help
with your "hiding" problem? (BTW - that last was a hint.)
AND PLEASE - don't post supposed "code snippets" again. Let us see what
you really ran if you want us to help. Or do you not know how to copy
and paste either? I/we can't help you if we can't see it.
Sorry to be so blunt.
--- End Message ---
--- Begin Message ---
On Tuesday, October 09, 2012 12:18:06 PM Jim Giner wrote:
> On 10/8/2012 11:11 PM, David McGlone wrote:
> > Hi all,
> >
> > is there any other way to limit this code to only displaying 1 image other
> > than using return. When I use return, I can't get the other images to
> > display in lightbox, but when I use echo, all 5 of the images will
> > correctly display in lightbox, but they are also displaying on the page.
> >
> > $result = mysql_query("SELECT * FROM properties");
> >
> > $row = mysql_fetch_array($result);
> > $matches = glob('images/property_pics/212006966/' .$prefix. '*');
> > foreach($matches as $match){
> > echo "<a href=$match rel='lightbox[$matches]' /><img src =
> >
> > $match></a>";
> >
> > I'm not even sure if this is possible, but thought I'd ask before I
> > scrapped the idea. I've been at this code since last thursday trying to
> > learn as much as I can about it and I just keep going in circles and I'm
> > starting to feel like glob() is what is limiting me. I've tried various
> > code blocks with things like where(), str_repeat, basename, scandir, sort
> > etc with no luck. :-/
> I hate to sound condescending, but you are showing some serious
> deficiencies in your programming ability. I have to say that you are
> tackling some very complex processes without the basic understanding of
> programming that one needs. What I base this opinion on is that since
> you first revealed your lack of understanding of Return and echo in php,
> you have spent another 3 days and STILL don't understand? Really?
I was afraid when I first posted that question, it would give that impression.
I've known what echo does, but not very much about return. Also a part of me
has always wondered when I'm studying code from things like wordpress I don't
think I have seen any echo statements. If I did it was very very few. (hint:
why I asked about templeting systems about a month ago.)
>
> As for the code above - once again it looks like you have posted a
> re-typing of some code you have tried to execute. I say that because
> you have a query and a fetch of one record of the results THAT HAS
> NOTHING TO DO WITH THE REST OF THE CODE!
The query is geting a number out of the database and putting the value in
$prefix.
> Also - you have an array
> being used as part of the Rel tag? What's up with that? (I think you
> meant to use $match - but that further verifies that this is NOT the
> code you ran.)
I tried using $match and $matches because I got confused there for a bit and
changed it.
>
> Finally - the code is (from your description) doing exactly what it is
> designed to do (the running code that is).
It sure is, and I found out what my whole problem was this morning before I
went to work. My problem was lightbox was not putting all the images in
$match. but I never suspected it until Matijn and Marco, posted an example of
code and It turned my attention to the piece of code....... put a bunch of
images in a folder and try running the code..... You'll see what I'm talking
about.
> All the (repeated) "echo"
> statements are going to put something on your web page.
Yes I was getting stuff on the page, and then when I'd try and build onto the
idea, and things broke, I'd try something else, and something else, until
finally I'm all confused with it. for example I'd forget to terminate something
and get a blank screen and imediately suspect it was the new code I
introduced. After the millionith time I started realizing when I get a blank
screen, I forgot my semicolon at the end of a line somewhere.
> The question
> you have is (apparently) how to hide them, since I believe Lightbox is
> going to have to have them present in order to do its thing.
That's part of it. the other part is that lighbox is supposed to do that
automatically and it should, and that's another reason I was getting confused.
like I said earlier run the code and you'll see what I'm saying.
> And so -
> in parting - I think you need to develop some html knowledge to
> facilitate that "hiding" part and some immediate skills in the general
> area of programming and learning to locate and read the right manuals.
> "Glob" is the least of your concerns.
>
> Yes - I'm being rough (I say this to you David as well as the rest of
> the community that is still interested in this post) but somebody has to
> make you realize that you are seriously in over your head and don't even
> know it.
I've said it many times, I am doing this to try and further my knowledge in
PHP and get past the basic echoing of variables and strings, and this is
nothing more than practice.
> Have you read a book on php and perhaps one on CSS to help
> with your "hiding" problem? (BTW - that last was a hint.)
I've read plenty of PHP books I own at least 5 and ALL of them I've read
hardly ever explain anything at all. They just throw some code in there and
say "this is what it does" and gives a picture of the finished product. Total
waste of my money! Also, how am I going to learn PHP if I've got to mix it all
up with CSS. It's just going to make things harder and more confusing on me. I
only threw lightbox in there because I knew I didn't have to do or learn
anything special and to put a smile on my face if it worked. After all, if it
can't be fun, why do it?
>
> AND PLEASE - don't post supposed "code snippets" again. Let us see what
> you really ran if you want us to help.
> Or do you not know how to copy
> and paste either? I/we can't help you if we can't see it.
That and only that is what I was running. I had changed it so many times
trying to learn that if something was screwed up, it was probably because,
before I posted, I had forgot to change it back.
>
> Sorry to be so blunt.
It's fine I kinda figured I'd be either ignored, or yelled at when I asked and
I
now know that I need to be a professional to ask questions here so there went
my confidence.
--
David M.
--- End Message ---