Technical Help & Discussion > Website Design & Programming

Request.

<< < (2/4) > >>

jimmy b:
I have dreamweaver mx ;D.

Yes start right at the beginning.

Are you only doing Sql? or the others aswell.

Where you get the disk from Bat?

Corky:
ok, the begining....

PHP:

php files must start with &lt;?PHP or &lt;?  lines are terminated by ; unless a { is there

to connect to MYSQL through PHP, use this code:

$connect = mysql_connect(&quot;localhost&quot;, &quot;databaseusername&quot;, &quot;databasepassword&quot;);//connects to the database
$select = mysql_select_db(&quot;databasename&quot;); //selects the database

$connect is now a short name for mysql_connect(&quot;localhost&quot;, &quot;databaseusername&quot;, &quot;databasepassword&quot;);
and $select is a short name for mysql_select_db(&quot;databasename&quot;); .  They may not need to be used that often, but some query's may need to use them from time to time.

Next, query's:

After typing the connect code add this code below mysql_select_db... :

$query = mysql_query(&quot;SELECT * FROM databasetable&quot;); //selects where the data is coming from in the table.

Now, if you want to display data from the database on a page you use:

while ($row = mysql_fetch_array($query)) {

$get1 = $row[&quot;get1&quot;];
$get2 = $row[&quot;get2&quot;];
$get3 = $row[&quot;get3&quot;];
//and so on.
now to display the data it has to be echo'd through php. So add:

echo&quot;$get1&quot;;
echo&quot;$get2&quot;; //html can be added here, but errors will emerge if there are &quot; (quotes) in the code, you can avoid the errors by adding a  in from of the &quot; so for example &lt;td height=&quot;20&quot;&gt; looks like this &lt;td heigh=&quot;20&quot;&gt;
echo&quot;$get3&quot;;
//and so on.
now that this data has been set to echo you can close this by adding a } at the end.

now close the code with ?&gt;

Fullcode:

&lt;?PHP

$connect = mysql_connect(&quot;localhost&quot;, &quot;databaseusername&quot;, &quot;databasepassword&quot;);
$select = mysql_select_db(&quot;databasename&quot;);
$query = mysql_query(&quot;SELECT * FROM databasetable&quot;);
while ($row = mysql_fetch_array($query)) {

$get1 = $row[&quot;get1&quot;];
$get2 = $row[&quot;get2&quot;];
$get3 = $row[&quot;get3&quot;];

echo&quot;$get1&quot;;
echo&quot;$get2&quot;;
echo&quot;$get3&quot;;

}

?&gt;


Right, who's still awake? ok rephrase... Who is still awake and understood a word of that?

Let me know what u are having trouble with and ill explain it more indepth.

Corky

jimmy b:
Corky I said at the begiinning ;D.

What does each one do and what they can be used for?

A very simple tutorial on using it?

Corky:
perhaps these ppl could teach you better.


http://www.webmasterbase.com/

Corky:
I didn't start using php with tutorials or help.  I jumped straight in at the deep end and edidted code of other peoples work.  I didn't copy it, i used it as a guide to build my own.

I think i will have to work on my tutorial building :)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version