Jump to content

zenag

Members
  • Posts

    443
  • Joined

  • Last visited

Everything posted by zenag

  1. can u show the form u used to post these values
  2. just verify it..... if($_POST['amend']){ $id=$_POST["id"]; $news=$_POST["news"]; $query = "UPDATE news SET news='$news' WHERE id = '$id'"; echo $query; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); } if($_POST['edit']) { foreach($_POST as $id) { $query = "SELECT * FROM news WHERE id = '$id'"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); if (mysql_num_rows($result) > 0) { $row = mysql_fetch_array($result); ?> <form action="<?php echo $PHP_SELF ?>" method="POST"> <input type="text" name="id" value="<?php echo $row["id"]?>"> <center> <table width="100%" border="0"> <tr> <td> </td> <td >News</td> </tr> <tr> <td> </td> <td> <textarea name="news" cols="55" rows="15"><?php echo $row["news"]; ?></textarea> </td> </tr> <tr> <td> </td> <td ><input name="amend" type="Submit" value="Amend" onclick="return confirm ('You are about to change this record, Are you sure you want to do this?');"/></td> </tr> <tr><td> <center></center> </td> </table> </center> </form> <?php //Otherwise no rows found } // end if $rowsFound body else echo "No rows found"; } }else if($_POST['delete']) { foreach($_POST as $id) { // loop through the checked checkboxes mysql_query("DELETE FROM news WHERE id='$id'"); // deletes the record from the database if (mysql_affected_rows() > 0) { // execute query print "<font color=red size=2>No. = $id has been deleted</font><p>"; } } }else{ $query = "SELECT * FROM news ORDER BY id"; $result = mysql_query($query)or die(mysql_error()); ?> <div class="smallerText"> <form name="action" id="action" method="post" action="<?=$_SERVER['PHP_SELF']?>"> <TABLE BORDER=1 WIDTH=100% CELLSPACING=3 CELLPADDING=3 ALIGN=CENTER bgcolor="#F7956A"> <TR> <td width="1%" bgcolor="#F0C9BF"><font color=red><b>ID</b></font></TD> <td width="100%" bgcolor="#F0C9BF"><font color=red><b>News</b></font></TD> <td width="1%" bgcolor="#F0C9BF" ><font color=red></font></TD> </tr> <? while ($row = mysql_fetch_array($result)) { extract($row); echo "<tr > <td>" . $row['id'] . "</td> <td>" . $row['news'] . "</td> <td>" ?> <input type="checkbox" name="<?=$row[id]?>" id="<?=$row[id]?>" value="<?=$row[id]?>"/> <? "</TD> </tr>"; } ?></table> <br><center> <input type="submit" name="edit" id="edit" value="Edit Selected" /> <input type="submit" name="delete" id="delete" value="Delete Selected" onClick="return confirm('Are you sure, you want to Delete this record?');"/> </center> </form></div> <? } ?>
  3. ur code seems to produce single result since u have not used loop while($row_del=mysql_fetch_array($result_del)) { $qry_del="DELETE from order_detail_table where order_id='$order_id' AND product_name='$product_name'"; echo $qry_del; }
  4. try this...code <? $name=$_FILES["files"]["name"]; $getext=strrchr($name, "."); if($getext==".Tiff") { $ext= strpos($name,'.'); $imagename=substr($name,0,$ext); $names=rtrim($name,'.Tiff').'.png'; $target="images/"; move_uploaded_file($_FILES["files"]["tmp_name"],$target.$names); } ?> <form action="" method="post" enctype="multipart/form-data"><input type="file" name="files"><input type="submit" name="submit" value="submit"></form>
  5. can u pls show the full table structure and required output format
  6. $postvalues=$_POST['myvariable']; class PS_Pagination { var $postvalues; function urfunction{ echo $this->$postvalues; }
  7. select * from table1 join table2 ON table1.fieldname = table2.fieldname
  8. zenag

    count

    SELECT count( field )as count1 , ( SELECT count( field ) FROM table2 ) AS count2 FROM table1
  9. zenag

    [SOLVED] Joins

    use count(*) or count(g.fieldname)not as count(g.*)
  10. zenag

    [SOLVED] Joins

    (SELECT COUNT(g.*) FROM games g WHERE g.playerID = p.playerID)as gamescount,(SELECT COUNT(t.*) FROM tries t WHERE t.playerID = p.playerID)as trycount
  11. SELECT * FROM `UserDetails`,`Ranks`WHERE `UserDetails`.`ID`=`Ranks`.`userID` ORDER BY Ranks.rank ASC
  12. its a sample code ...try this out.. <?php $username = "user"; $password = "pass"; $randomword = "bibblebobblechocolatemousse"; if($_GET["logout"]=="yes") { setcookie("MyLoginPage","",time()-3600); header("Location: $_SERVER[php_SELF]"); } if (isset($_COOKIE['MyLoginPage'])) { if ($_COOKIE['MyLoginPage'] == md5($password.$randomword)) { echo "<a href='?logout=yes'>logout</a>"; ?> <?php exit; } else { echo "<p>Bad cookie. Clear please clear them out and try to login again.</p>"; exit; } } if (isset($_POST['p']) && $_POST['p'] == "login") { $name = trim($_POST['name']); if (empty($name)) { $error['name'] = '*'; } if ($_POST['name'] == $username && $_POST['pass'] == $password && !$error) { setcookie('MyLoginPage', md5($_POST['pass'].$randomword)); header("Location: $_SERVER[php_SELF]"); } else { echo "* fields are required"; } } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"><fieldset> <label><input type="text" name="name" id="name" /> Name</label><label><? echo $error['name'] ?></label><br /> <label><input type="password" name="pass" id="pass" /> Password</label><br /> <input type="hidden" name="p" value="login" /> <input type="submit" id="submit" value="Login" /> </fieldset></form>
  13. //just set time in setcookie to delete cookie... $username = "user"; $password = "pass"; $randomword = "bibblebobblechocolatemousse"; if($_GET["logout"]=="yes") { setcookie("MyLoginPage","",time()-3600); header("Location: $_SERVER[php_SELF]"); } if (isset($_COOKIE['MyLoginPage'])) { if ($_COOKIE['MyLoginPage'] == md5($password.$randomword)) { echo "<a href='?logout=yes'>logout</a>"; ?> <?php exit; } else { echo "<p>Bad cookie. Clear please clear them out and try to login again.</p>"; exit; } }
  14. $ip = mysql_query("select ip FROM timetoclick WHERE ip='".$_SERVER['REMOTE_ADDR']."'"); $fetchip = mysql_fetch_row( $ip ); $posttime = mysql_query("select posttime FROM timetoclick WHERE ip='".$_SERVER['REMOTE_ADDR']."'"); $fetchtime = mysql_fetch_row( $posttime ); if ($fetchip[0] != $_SERVER['REMOTE_ADDR']) { mysql_query("INSERT INTO timetoclick (ip, posttime) VALUES ('".$_SERVER['REMOTE_ADDR']."', '".time()."')"); echo "New<br>"; } elseif ($fetchtime[0]-43200>time()) { echo "You have allreact been attacked. You can not be attacked by this person for X"; echo " more seconds."; } else { mysql_query("INSERT INTO timetoclick (ip, posttime) VALUES ('".$_SERVER['REMOTE_ADDR']."', '".time()."')"); echo "New<br>"; } ?>
  15. while($fetchip = mysql_fetch_array( $ip )) ...will fetch values in array try this... $fetchip = mysql_fetch_row( $ip ); echo $fetchip[0];
  16. ORDER BY Level DESC,Members DESC
  17. '=' & echo seems missing... <input type="hidden" name="eventTitle" id="eventTitle" value="<?php echo $eventTitle ?>" /> <input type="hidden" name="eventTime" id="eventTime" value="<?php echo $eventTime ?>" /> <input type="hidden" name="eventDate" id="eventDate" value="<?php echo $eventDate ?>" />
  18. your insert query shows error...try mysql_error() to dispaly what kind of error.. ... $insert = mysql_query("INSERT INTO $tbl_online (id, timestamp, ip, file, ol_user, ol_id) VALUES(\"$_SESSION[member_id]\",'$timestamp','".$_SERVER['REMOTE_ADDR']."','".$_SERVER['PHP_SELF']."','$ol_user','$ol_id')") or die(mysql_error());
  19. <?php if (array_key_exists('submit', $_POST)) { // validate the input, beginning with name .......................... .................................. $email = $_POST['emailaddress']; // check for valid email address $pattern = '/^[^@]+@[^\s\r\n\'";,@%]+$/'; if (!preg_match($pattern, trim($email))) { $error['emailaddress'] = '*'; } // check the content of the text area $comments = trim($_POST['comments']); if (empty($comments)) { $error['comments'] = '*'; } if(!$error) { header("location:yourpage.php"); } } ?>
  20. $link = "http://rilana.biz/uploads/".basename( $_FILES['uploadedfile']['name']) ;
  21. SELECT DATE_FORMAT( date_field, '%Y-%m-%d' ) FROM `my_table` WHERE date_field = CURDATE( )
  22. $checklist=urlencode(serialize($_GET['check_list'])); echo "<img src=\"./linegraph.php?v1=".$checklist."&start=$start_dt&end=$end_dt\">"; in linegraph.php $ckecklist=unserialize(urldecode(stripslashes($_GET['v1'])));
  23. .....assign post values to variable before insert action... $studid=implode(',',$_POST['actions2']); mysql_query("Insert into spbtborrow(studentid,bookpackage) Values('$studid','$package')");
  24. here $grabbed_date must be string....single or double quoted... $grabbed_date='20-03-2008'; echo date('m/d/Y',strtotime($grabbed_date));
×
×
  • 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.