What is PHP?
PHP stands for PHP: Hypertext Preprocessor
PHP is a server-side scripting language, like ASP
PHP scripts are executed on the server
PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
PHP is an open source software
PHP is free to download and use
What is MySQL?
MySQL is a database server
MySQL is ideal for both small and large applications
MySQL supports standard SQL
MySQL compiles on a number of platforms
MySQL is free to download and use
mysql_connect
$con = mysql_connect("localhost","root","ednalan");
mysql_select_db("dbednalan", $con);
$sql = mysql_query("select * from dir_buscoupon WHERE busid = '{$_GET['busid']}'");
$rs = mysql_fetch_array($sql);
$id = $rs["id"];
$img = $rs["img"];
mysql_fetch_array
//1. list records where condition
$sql = mysql_query("select * from registrations WHERE id='$id'" ORDER BY asign_number Asc); ///////DESC Limit 5";
$rs = mysql_fetch_array($sql);
$id = $rs["id"];
$email = $rs["email"];
//2. while loop
define("REGISTRATION", "registration");
$sql_welcome = "SELECT * FROM ".REGISTRATION;
$sql_result = mysql_query($sql_welcome) or die("Could not connect");
while ($sql_row= mysql_fetch_array($sql_result, MYSQL_ASSOC)){
echo $sql_row['welcome'];
}
$sql="Select * From dbisubcategory";
$db_query=mysql_query($sql) or die("Could not requery");
while ($result=mysql_fetch_array($db_query, MYSQL_ASSOC))
{
$About=$result['id'];
echo($About);
}
//3 where condition
$result=mysql_query("SELECT * FROM gb_users where status='admin'") or die('Error 3- No database found.');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$mail=$row['email'];
//4. Define table in view records in table
define("ABOUT", "tblabout");
$sql_announcement = "SELECT * FROM ".ABOUT." WHERE id=4";
$sql_result = mysql_query($sql_announcement) or die("Could not connect");
echo "
$sql_row[About] |
//5 get variables
$sql = mysql_query("select * from dir_buscoupon WHERE busid = '{$_GET['busid']}' AND id = '{$_GET['id']}'");
$rs = mysql_fetch_array($sql);
$id = $rs["id"];
$img = $rs["img"];
mysql_fetch_assoc
$qry = mysql_query("SELECT * FROM events WHERE id = '$event_id'") or die(mysql_error());
$rows = mysql_fetch_assoc($qry);
$event = $rows['name'];
mysql_num_rows
$sqld = "SELECT * FROM dir_coupon_print WHERE busid = '{$_GET['busid']}' AND userid = '{$_GET['iuser']}'";
$result = mysql_query($sqld);
$total = mysql_num_rows($result);//total
//echo $total;
if (mysql_num_rows($result)>0){ //no records founds
while ($rw = mysql_fetch_array($result, MYSQL_ASSOC)){
if (($dateadd >! $rw['dateexpire'])) {
echo "You already consume coupon for this business. wait 24 hours before printing the coupon again. ";
}else{
updateCoupon($rw['id']); //UPDATE RECORDS
}
}
}else {
insertCoupon($record); //INSERT RECORDS
}