Jump to content
Hostul a fost schimbat. Daca vedeti serverul offline readaugati rpg.b-zone.ro sau 141.95.124.78:7777 in clientul de sa-mp ×

[PHP Tutorial] Ep1 Variabile [HD]


Vennom
 Share

Recommended Posts

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 !

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.