http://www.youtube.com/watch?v=nUDzjNQVxLk&feature=youtu.be
DEMO:
http://vennom.b-zone.ro/tutorials/php/variabile.php
Coduri:
* Adunarea cu variabile:
<?php
$a='1';
$b='4';
$c=$a+$b;[/font]
[font=georgia,serif]echo "O adunare simpla este $a+$b=$c";
?>
*Functia IF:
<?php
$bz='bobo';[/font]
[font=georgia,serif]if ($bz == bobo) {
echo "El este Bobo !";
} else {
echo "El nu este Bobo !";
}[/font]
[font=georgia,serif]if ($c < 6) {
echo "<br><br>5 este un numar mai mic decat 6";
}
if ($c > 4) {
echo "<br>5 este un numar mai mare decat 4";
}
?>
* MySQL
Conectare:
<?php
$con = mysql_connect("HOST", "USER", "PASSWORD");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("BAZA_DATE", $con);
?>
Variabile in MySQL:
<?php
$sel = mysql_query("SELECT * FROM variabile WHERE numar='1'");
$check = mysql_num_rows($sel);
$check2 = mysql_fetch_row($sel);[/font]
[font=georgia,serif]echo "Am <b>$check</b> rand(uri) in tabel cu numele: <b>$check2[1]</b> si varsta <b>$check2[2]</b>";
?>
Nota:
- In loc de 'variabile' la prima linie scrieti numele tabelului;
- in loc de 'numar=1' la prima linie scrieti numele coloanei;
Pentru a intelege ce am scris mai sus vezi clipul !