PHP Example for Subscriber List: Difference between revisions
Jump to navigation
Jump to search
ELQ Homewood (talk | contribs) No edit summary |
ELQ Homewood (talk | contribs) No edit summary |
||
| Line 64: | Line 64: | ||
This isn't tested or anything but it should be pretty close, to give an idea what you're | This isn't tested or anything but it should be pretty close, to give an idea what you're | ||
function script will be. | function script will be. [[User:ELQ Homewood|ELQ Homewood]] 04:33, 2 November 2009 (UTC) | ||
Revision as of 21:33, 1 November 2009
Something like..
<?php
//db connect variables
$host = "mysql server address";
$user = "mysql username";
$pw = "mysql password";
$db = "mysql database name";
//connect to db
$con = mysql_connect($host,$user,$pw);
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db($db, $con);
//get variables from script
$uuid = $_REQUEST['UUID'];
$cm = $_REQUEST['command'];
//process variables
switch($cm) {
case "add":
if(!mysql_query("SELECT * FROM tbl_News WHERE uuid = '$uuid'")) {
mysql_query("INSERT INTO tbl_News VALUES ('$uuid')");
}
//return to script
echo $cm." complete.";
break;
case "rem":
mysql_query("DELETE FROM tbl_News WHERE uuid='$uuid'");
//return to script
echo $cm." complete.";
break;
case "tot":
if($uuid = "") { //place your key between the quotes here
$q = mysql_query("SELECT * FrOM tbl_News");
$tot = mysql_num_rows($q); //get the total entries in the table
}
//return to script
echo $cm."|".$tot;
break;
case "dist":
$dist = mysql_query("SELECT * FROM tbl_News");
while($row = mysql_fetch_array($dist))
{
echo $row['uuid'];
sleep(20);
}
break;
}
mysql_close($con);
?>
This isn't tested or anything but it should be pretty close, to give an idea what you're function script will be. ELQ Homewood 04:33, 2 November 2009 (UTC)