Thanks a lot devinemke, I see - OK.
mysql_query($sql);
The last think what I need to end my guestbook is in guestbook.php file, which store the entered data from flash guestbook to guestbook table.
Now I need to return to flash only the values with 1 - TRUE of column 'iAproved'.
Here is the code from guestbook.php which displays all data:
$action = $_REQUEST['action'];
switch($action):
case "view":
$str = "";
$query = "SELECT * FROM guestbook ORDER BY gid DESC";
// select aproved comments
//$query = "SELECT * FROM guestbook WHERE isApproved = 'Yes' ORDER BY gid DESC";
$rs = mysql_query($query);
if(!$rs){
$count = 0;
} else {
$count = mysql_num_rows($rs);
}
if ($count>0) {
while ($var=mysql_fetch_assoc($rs)){
$str .= $var["gflash"] . "<br/>";
}
$str .= "<br/><br/> ::::::::::::: End of Entries ::::::::::::::: ";
} else {
$str=":: Nothing to Display ::";
}
//---------------------------------- Send the results to flash -----------------------------------------\\
echo "&strflash=$str";
break;
case "add":
//-------------------------- Grab variables from the POST ---------------------------\\
foreach($_POST as $key => $value){
$$key = $value;
}
$gdate = date("Y-m-d H:i:s");
$err = "Problem posting";
//-------------------------- Prepare HTML to returm to flash ---------------------------\\
$gflash = "<b>Name: </b>$gname<br/><b>From: </b>$gfrom<br/><b>Message: </b>$gmsg<br/><b>Posted: </b><i>$gdate</i><br/>";
//-------------------------- Insert info to database ---------------------------\\
// $query = "INSERT INTO guestbook(gdate,gname,gmail,gfrom,gmsg,gflash,isAproved) VALUES ('$gdate','$gname','$gmail','$gfrom','$gmsg','$gflash','NO')";
$query = "INSERT INTO guestbook(gdate,gname,gmail,gfrom,gmsg,gflash) VALUES ('$gdate','$gname','$gmail','$gfrom','$gmsg','$gflash')";
$rs = mysql_query($query);
if($rs){
echo "&posted=true";
echo "&gflash=$gflash";
} else {
echo "&error=$err";
echo "&gflash=$gflash";
}
break;
endswitch;
I need to prepare $gflash only with record with value TRUE of 'isApoved' column. Now displays all.
Thank you for your time.
devinemke wrote:my example posted above does not actually run the UPDATE query, it just outputs it for you to see the syntax. you have to run the query using [man]mysql_query[/man].