Jump to content

katierosy

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.sourcebits.com/

Profile Information

  • Gender
    Not Telling

katierosy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. If you will use for loop instead of foreach it will make your tas easy. This should make it clear. <?php for($i=0;$i<count($result);$i++){ if($result[$i-1]['fieldname']=='value' && $result[$i]['fieldname']=='value'){ // update with the $i-1 index or $i index } } ?>
  2. If you will post the forms html code part along with the mytsql code part, we will be able to help. It will help us more, if you will mention which line number might have issues, means where the code fails to do the jobs it is meant to do.
  3. It will be good if you just use print_r($array) to see the structure of array and change the array structure as required in your case. <?php $str1['x']=5; $str1['y']=6; $str[]=$str1; $str1['x']=1; $str1['y']=2; $str[]=$str1; $str1['x']=4; $str1['y']=3; $str[]=$str1; $str1['x']=8; $str1['y']=2; $str[]=$str1; print_r($str); foreach($str as $row){ $m[$key] = $row['x']; $n[$key] = $row['y']; $x[]= $row } ?>
  4. I do not see , there is an issue with form post. Only when i check the values posted and correct values too. Please let us know where you have faced the error. <?php if (isset($_POST['submitted'])) { $errors = array(); $descriptor1 = trim($_POST['plant_id']); $descriptor4 = trim($_POST['alternative']); $descriptor5 = trim($_POST['aromatherapy']); $descriptor6 = trim($_POST['bach']); $descriptor17 = trim($_POST['chocolate_substitute']); $descriptor18 = trim($_POST['coffee_substitute']); $descriptor19 = trim($_POST['coloring']); if (empty($errors)) { print_r($_POST); //require ('3_z_mysq1_c0nn3ct.php'); /*$query = "INSERT INTO plant_edible_link(plant_id, edible_id) VALUES ('$descriptor1', '$descriptor17'), ('$descriptor1', '$descriptor18'), ('$descriptor1', '$descriptor19'), $result = mysql_query ($query); $query = "INSERT INTO plant_medicine_link(plant_id, medicine_id) VALUES ('$descriptor1', '$descriptor4'), ('$descriptor1', '$descriptor5'), ('$descriptor1', '$descriptor6'), $result = @mysql_query ($query);*/ if ($result) { echo 'one plant has been added'; exit(); } else { echo 'system error. No plant added'; echo '<p>' . mysql_error() . '<br><br>query:' . $query . '</p>'; exit(); } //mysql_close(); } else { echo 'error. the following error occured <br>'; foreach ($errors as $msg) { echo " - $msg<br>\n"; } } // end of if } // end of main submit conditional ?> <FORM action="form1.php" method="post"> <br> Plant relationships, part 2<br> <table bgcolor=#FFEC8B width=590> <tr><td> plant id:<br> only enter numbers here<br> <input type="text" name="plant_id" value="<?php if(isset($_POST['plant_id'])) echo $_POST['plant_id']; ?>" /> <br> Medical Uses:<br> <input type="checkbox" name="alternative" value="1" > Alterative <br> <input type="checkbox" name="aromatherapy" value="2" > Aromatherapy <br> <input type="checkbox" name="bach" value="3" > Bach <br> <br><br> <table bgcolor=#FFEC8B width=590> <tr> <td> Edible Uses:<br> <input type="checkbox" name="chocolate_uses" value="14" > Chocolate substitute<br> <input type="checkbox" name="coffee_substitute" value="24" > Coffee substitute<br> <input type="checkbox" name="coloring" value="34" > Coloring <br> </fieldset><br><br> <input type="hidden" name="submitted" value="TRUE"> <input type="submit" /> </form>
  5. Hope this example will make it easy and clear to accomplish the task as mentioned in this forum. <?php $str1['win']=5; $str1['loss']=6; $str[]=$str1; $str1['win']=1; $str1['loss']=2; $str[]=$str1; $str1['win']=4; $str1['loss']=3; $str[]=$str1; $str1['win']=8; $str1['loss']=2; $str[]=$str1; print_r($str); foreach($str as $key => $row) { $win[$key] = $row['win']; $loss[$key] = $row['loss']; } array_multisort($win,SORT_DESC,$loss,SORT_ASC,$str); print_r($str); ?>
  6. This link as below talks about property procedure let,get,set and it's rule. http://editorial.co.in/software/vbscript_property_let_get_set.php In PHP such let,get,set procedures may not be available. Nonetheless it works as you have mentioned get,set methods to do similar tasks.
  7. If you will read number of pagination scripts from web, you will be helped to do it the way you want.
  8. The link below may help http://forums.devshed.com/php-development-5/insert-update-delete-in-xml-file-using-php-699891.html
  9. Please let us know exactly the point/stage of difficulty. If you are new to PHP, you may read some example scripts on web and try to read and understand them.
  10. You may use javascript without the use of ajax as below, hope this will work fine. If not please look into the jquery library and using ajax with it, for more help. <script> function addpoint(userid,point){ document.form1.userid=userid; document.form1.point=point; document.form1.submit(); } </script> <a href="javascript:void(0);" onclick="addpoint(445656888,100)">Add 100 Point</a> <a href="javascript:void(0);" onclick="addpoint(878655644,100)">Add 100 Point</a> <form method="post" action="thispage.php" name="form1"> <input type="hidden" name="point" value=""> <input type="hidden" name="userid" value=""> </form>
  11. Please see http://www.phpbuilder.com/board/showthread.php?t=10283679 and also please read some more examples on paging. To write a much better paging code.
  12. We do not find any error message on both the site links mentioned. May be you have already found out the issue.
  13. Nonetheless to us this is correct. If like is used you are escaping %. in addtion to mysql_real_escape_string
  14. It shows the table name in the sql is not there. If it is there , then please ensure correct database information host,user,password
  15. You may use this function. It works already tested. <?php function SendMail($emailaddress,$from,$fromaddress,$emailsubject="",$body="", $html = true,$attachment="",$encoding="utf-8"){ if (strtoupper(substr(PHP_OS,0,3)=='WIN')) { $eol=""; } elseif (strtoupper(substr(PHP_OS,0,3)=='MAC')) { $eol="\r"; } else { $eol="\n"; } if ($encoding != "utf-8" && !empty($body)) { $body = mb_convert_encoding($body, $encoding, "utf-8"); } $msg = ""; # Common Headers $headers .= "From: ".$from." <".$fromaddress.">".$eol; $headers .= "Reply-To: ".$from." <".$fromaddress.">".$eol; $headers .= "Return-Path: ".$from." <".$fromaddress.">".$eol; $headers .= "Message-ID: <".time()." serv@".$_SERVER['SERVER_NAME'].">".$eol; $headers .= "X-Mailer: PHP v".phpversion().$eol; $headers .= 'MIME-Version: 1.0'.$eol; if (!empty($attachment)) { //send multipart message # Boundry for marking the split & Multitype Headers $mime_boundary=md5(time()); $headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol; # File for Attachment $f_name = $attachment; $handle=fopen($f_name, 'rb'); $f_contents=fread($handle, filesize($f_name)); $f_contents=chunk_split(base64_encode($f_contents)); $f_type=filetype($f_name); fclose($handle); # Attachment $msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: application/jpeg; name=\"".$file."\"".$eol; $msg .= "Content-Transfer-Encoding: base64".$eol; $msg .= "Content-Disposition: attachment; filename=\"".basename($attachment)."\"".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !! $msg .= $f_contents.$eol.$eol; # Setup for text OR html $msg .= "Content-Type: multipart/alternative".$eol; $contentType = "text/plain"; if ($html) { $contentType = "text/html"; } # Body $msg .= "--".$mime_boundary.$eol; $msg .= "Content-Type: ".$contentType."; charset=\"".$encoding."\"".$eol; $msg .= "Content-Transfer-Encoding: 8bit".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !! $msg .= $body.$eol.$eol; # Finished $msg .= "--".$mime_boundary."--".$eol.$eol; // finish with two eol's for better security. } else { $headers .= "Content-Type: text/plain; charset=\"".$encoding."\"".$eol; $headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol; // !! This line needs TWO end of lines !! IMPORTANT !! $msg .= $body.$eol.$eol; } ini_set(sendmail_from, $fromaddress); //needed to hopefully get by spam filters. $success = mail($emailaddress, $emailsubject, $msg, $headers); ini_restore(sendmail_from); return $success; } ?>
×
×
  • 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.