Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Demo example

Hi,
is there any example in PHP to have multiple pages shown, to which I can each time press "Page down" to scroll to next page?
Avatar of weaverk
weaverk
Flag of Switzerland image

since your pages are already shown, and php is server side - its no longer involved

 you could take a look at anchor tags or some javascript plugins for this

example - http://davist11.github.io/jQuery-One-Page-Nav/
Avatar of Peter Chan

ASKER

Thanks.
How can I further show "Usage" and "Examples" (from your example), with different picture file?
if you mean change background image, the easiest way is to use the css 'VH' property

example: http://codepen.io/anon/pen/ojNxbQ


please note this does not work in very old browsers (ie 8 etc)
Many thanks.
The url now does retrieve file from DB. is there any similar example/demo, that is retrieving picture files from the OS instead?
PHP runs on the server.  Client information is displayed in the browser.  Because of this division of labor, it might make sense to organize this application in the form of a JavaScript call to a PHP API.  One of the popular modern tools for this is AngularJS, from Google.
https://angularjs.org/
Yes, I want to display picture files (that are from the server), on the page. Any sample/demo to this?
In HTML we use the <img> tag to display images from the server on the client browser.  You can manipulate the Document Object Model with JavaScript.  This book will teach you all you need to know about JavaScript.  It is the only JS book I recommend.
http://www.barnesandnoble.com/p/javascript-david-flanagan/1103237657/2672114789478

JavaScript can be simplified (sometimes) by using jQuery.  All the docs for jQuery are online.

AngularJS (linked earlier) has extensive online documentation.
Sorry to that, I expect to see one working example.
HuaMinChen,

your 1st question "how do i use php for rendering client side things" - was answered, with example

your 2nd question - "how do i handle background images in CSS" - was answered, with example

your 3rd question - "how to use images on the server in my code" - i will answer now, either replace the url part of my example with '//yoursite.com/path/to/image/imageName.extension' or, with the relative path on the server e.g. ../img/imageName.extension, from what you are asking, its the second option you are looking for, please see explanation

your 4th question - "show me how to build a website with angularJS" - nobody can answer here, if you are curious there are good video tutorials on youtube, online learning courses at teamtreehouse.com, and plenty of other resources out there via google.

Cheers,
W.
Hi,
I want to show this picture

/home/huamin/Downloads/emu_wild_animal_bird.jpg

on PHP codes. how?
<img src="<?php echo '/home/huamin/Downloads/emu_wild_animal_bird.jpg'; ?>" alt="picture description here">

Open in new window

link
Can I put such line into one PHP file? Any other details to the PHP file?
Any advice to this error
[root@CentOS65x64 html]# php -f info3.php
PHP Parse error:  syntax error, unexpected '<' in /var/www/html/info3.php on line 2

due to this file?

<?php
<img src="<?php echo '/home/huamin/Downloads/emu_wild_animal_bird.jpg'; ?>" alt="picture description here">
?>
you have double <?php....?> remove the outside ones


<?php
<img src="<?php echo '/home/huamin/Downloads/emu_wild_animal_bird.jpg'; ?>" alt="picture description here">

Open in new window

?>

reading matter
This question might be easier to answer if we shared a background of understanding in how the technologies work together.

PHP and MySQL run on the server; they generate the HTML, CSS, and JavaScript statements that are sent to the client.  This is called a "response" or "document" and it is sent in response to a "request" from a client machine.  The most familiar version of a "request" is a browser, where we type a URL to visit a web site.  This relationship is known as the HTTP Client/Server Protocol.

The image tag is part of the HTML sent to the client machine.  It contains a URL for the image.  This URL is resolved through rules related to the directory structure on the client machine.  It is unlikely that the URL of the image would include working directory paths known only to the web server.  My guess is that this URL would be correct (but it is only a guess because I do not have access to your server to make a test).
<img src="<?php echo 'Downloads/emu_wild_animal_bird.jpg'; ?>" alt="picture description here">

Open in new window

If you're new to these web development technologies and want to learn them, SitePoint has a great collection of materials - books, online forums, articles, etc.  There are others, of course, but in my experience, SitePoint is pretty good.  If you already know HTML, CSS and JavaScript, and just want to learn PHP, this article can help you find dependable learning resources.  But if you don't already know HTML, CSS and JavaScript, I would recommend studying those technologies in that order before tackling the server-side programming.
Sorry, I get nothing shown, by this

[root@CentOS65x64 html]# php -f info3.php
<img src="/home/huamin/Downloads/emu_wild_animal_bird.jpg" alt="picture description here">

[root@CentOS65x64 html]#
After I've removed the outer one

<?php....?>

to the file.
ASKER CERTIFIED SOLUTION
Avatar of weaverk
weaverk
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Many thanks. How can I now refer to the specific PHP file, from the browser?
What URL should I use now, to open it within Browser?
On my current machine.
The original question (and several others) have been answered here, i suggest you ask separate questions for further problems.

The most likely solution would be to access http://localhost/yourfilename.php IF your file is in the root of your server - but only you know this... for more details find a tutorial on setting up LAMP (Linux, Apache, MySQL, PHP) stack, to understand better where your files are
I copy the .php file to /root, but then I've got this

User generated image