Note that there are some explanatory texts on larger screens.

plurals
  1. PObest approach in filling up a profile page?
    primarykey
    data
    text
    <p>Well I am a newbee so kindly please ignore if there is any mistake in my question,I have this question on my mind.Iam just creating a small website like a profile information.</p> <p>Okay see when user logs in with his email into the website, we use php scripting and retrieve the data from mysql and put that data in the page using mostly <code>printf</code> or <code>echo</code></p> <p>So there is possibilty of 2 ways to do</p> <p>for example one of the table of my database looks like this</p> <pre><code> name birthday aboutme gender dreams music movies blabla// someperson xx xx xx xx xx xx </code></pre> <p><strong>first method</strong> demo.php</p> <pre><code> &lt;html&gt; &lt;body&gt; name: &lt;?some php script to get user name?&gt; &lt;20 lines of html tags and data&gt; birthday: &lt;?some php script to get user name?&gt; &lt;20 lines of html tags and data&gt; about user &lt;?some php script to get user about?&gt; &lt;some more html data&gt; &lt;?some more php scripting?&gt; </code></pre> <p>In the first method we are always connecting to the database and getting the data and then after 20 lines of html code and then again we are connecting to the same table and database and getting the next columns value and disconnecting it and then again we are connecting to the server and more. In this process we are connecting and disconnecting from server</p> <p>So in the first method we are always connecting and disconnecting from server, I was just thinking it may cause a serious overhead on the server as we are connecting and disconnecting for every 10 lines of code.is my thinking true or is there anything wrong?</p> <p><strong>second method</strong> demo.php</p> <pre><code> &lt;?php retrieve all the data you need at a time here and then use echo "&lt;html&gt;" echo "&lt;body&gt;" echo "name: &lt;?just php variable value that was retrieved?&gt; echo "&lt;20 lines of html tags and data&gt;" echo "birthday: &lt;?just php variable value that was retrieved?&gt; ?&gt; </code></pre> <p>In the second method we are using the php script run by server just get the data at the start and then just echo them with the html tags and data that was retrieved, but i was thinking it is so unneccasary because we are making the server to execute the html tags where a normal browser clearly would do</p> <p>I am finding both ways causing a serious overhead issue on the server.could anyone explain what is the best way to do it? is there any other way the professionals choose , I am not sure how they make through it.</p> <p>Well is there a way to retrieve the data at once from the database and then just echo it back between the html tags?</p> <p><strong>simply like</strong></p> <pre><code> &lt;?get all the data from database here&gt;? &lt;div&gt; echo 'some php variable' &lt;span&gt; echo 'some php variable' </code></pre> <p>Is there a way like this? Kindly let me know the best approach to do it.Thanks</p> <p>any help is greatly appreciated </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload