Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by sasa

  1. try <?php mysql_connect('localhost', 'username', 'password'); //change to your username and password mysql_select_db('peterodc_selfbuild'); foreach ($_POST['materials'] as $mater){ $name = $mater['name']; //or is it $id (not sure... anyone more help) $material = $mater['material']; $stage = $mater['stage']; $unit = $mater ['unit']; // satanize inputs $sql = mysql_query("UPDATE materials SET material='$material', stage='$stage', quantity='$quantity',unit='$unit' WHERE id='$name'"); } ?>
  2. look here http://www.phpfreaks.com/forums/index.php/topic,95426.0.html
  3. <?php foreach ($_POST['materials'] as $mater){ $name = $mater['name']; //or is it $id $material = $mater['material']; $stage = $mater['stage']; //and so on // satanize inputs mysql_query("UPDATE table_name SET material='$material', stage='stage' etc. WHERE id='$name'"); } ?> and add disabled="disabled" atribute to your input tag for id_number
  4. try to cange form to <? // Connect database. $host="localhost"; // Host name. $db_user="test"; // MySQL username. $db_password="test"; // MySQL password. $database="test"; // Database name. mysql_connect($host,$db_user,$db_password); mysql_select_db($database); // Select all data records in table "name_list" and put them into $result. $result=mysql_query("select * from Players"); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="post" action="playerupdate.php"> <table border="1" cellpadding="3" cellspacing="0"> <td align="center" bgcolor="#FFCC00"><strong>Clan</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Name</strong></td> <td align="center" bgcolor="#FFCC00"><strong>GP</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Scores</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Kills</strong></td> <td align="center" bgcolor="#FFCC00"><strong>Deaths</strong></td> <td align="center" bgcolor="#FFCC00"><strong>SPG</strong></td> <td align="center" bgcolor="#FFCC00"><strong>KPG</strong></td> <td align="center" bgcolor="#FFCC00"><strong>K/D</strong></td> <td align="center" bgcolor="#FFCC00"><strong>FA</strong></td> <td align="center" bgcolor="#FFCC00"><strong>FC</strong></td> <td align="center" bgcolor="#FFCC00"><strong>FP%</strong></td> <td align="center" bgcolor="#FFCC00"><strong>MVP</strong></td> </tr> <? // Fetch record rows in $result by while loop and put them into $row. while($row=mysql_fetch_assoc($result)){ $id = $row['Player']; // if 'Player' is primary key of your table ?> <tr> <td bgcolor="#FFFFCC"><input name="ClanName[<? echo $id; ?>"] size="4" type="text" id="<? echo $row['ClanName']; ?>" value="<? echo $row['ClanName']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="Player[<? echo $id; ?>"] size="15" type="text" id="<? echo $row['Player']; ?>" value="<? echo $row['Player']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="GP[<? echo $id; ?>"] size="4" type="text" id="<? echo $row['GP']; ?>" value="<? echo $row['GP']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="Scores[<? echo $id; ?>"] size="4" type="text" id="<? echo $row['Scores']; ?>" value="<? echo $row['Scores']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="Kills[<? echo $id; ?>"] size="4" type="text" id="<? echo $row['Kills']; ?>" value="<? echo $row['Kills']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="Deaths[<? echo $id; ?>"] size="4" type="text" id="<? echo $row['Deaths']; ?>" value="<? echo $row['Deaths']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="SPG[<? echo $id; ?>"] size="4" type="text" id="<? echo $row['SPG']; ?>" value="<? echo $row['SPG']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="KPG[<? echo $id; ?>"] size="4" type="text" id="<? echo $row['KPG']; ?>" value="<? echo $row['KPG']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="KD[<? echo $id; ?>"] size="4" type="text" id="<? echo $row['KD']; ?>" value="<? echo $row['KD']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="FA[<? echo $id; ?>"] size="4" type="text" id="<? echo $row['FA']; ?>" value="<? echo $row['FA']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="FC[<? echo $id; ?>"] size="4" type="text" id="<? echo $row['FC']; ?>" value="<? echo $row['FC']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="FP[<? echo $id; ?>"] size="4" type="text" id="<? echo $row['FP']; ?>" value="<? echo $row['FP']; ?>" /></td> <td bgcolor="#FFFFCC"><input name="MVP[<? echo $id; ?>"] size="4" type="text" id="<? echo $row['MVP']; ?>" value="<? echo $row['MVP']; ?>" /></td> </tr> <? } // End while loop. ?> </table> <input type="submit" name="Submit" value="Update" /> </form> </body> </html> and 2nd page to <? if($_POST['Submit']){ // If receive Submit button variable. $host="localhost"; // Host name. $db_user="test"; // MySQL username. $db_password="test"; // MySQL password. $database="test"; // Database name. mysql_connect($host,$db_user,$db_password); mysql_select_db($database); foreach ($_POST['Player'] as $id => $Player){ $ClanName = $_POST['ClanName'][$id]; $GP = $_POST['GP'][$id]; // etc. mysql_query("UPDATE Players SET ClanName='$ClanName', GP='$GP' WHERE Player='$id'"); } echo "--- Update Complete ---"; } ?>
  5. lcd(a, b) * gcd(a, b) = a * b <?php function gcd($a, $b){ if ($a < 1 or $b < 1 or $a != (int) $a or $b != (int) $b) return false; while ($r = $a % $b){ $a = $b; $b = $r; } return $b; } function lcd($a, $b){ if ($gcd = gcd($a, $b)) return $a * $b / $gcd; else return false; } function lcd_a($array){ if (count($array) == 2) return lcd(array_pop($array), array_pop($array)); $a = array_pop($array); return lcd(lcd_a($array), $a); } echo lcd(5,6) echo lcd_a(array(4,5,6)); ?>
  6. try <?php $text = '<a href="http://www.yoursite.com"> blah blah <a href="http://www.yoursite.com/xxx"> <a href="http://www.mysite.com?url=http://www.yoursite.com/11"> <a href=".../exit.php?url=http://www.mysite.com">'; $text = preg_replace('#(?<=\<a href="http://)(?!www\.mysite\.com)([^"]*)#', 'www.mysite.com?url=http://\1', $text); print_r($text); ?>
  7. look http://www.weberdev.com/get_example-3688.html
  8. are you try $post = array_chunk($fileURL, 5); print_r($post);
  9. tryfcode]<?php function DisplayQuizResults() { // Determine That The User Has Come To This Page From // A Proper Quiz Page if( !isset( $_POST[ 'submit' ] ) ) { // Invalid Access die( "Sorry, direct access to this file is not permitted.\n" ); } // Obtain Username if( isset( $_POST[ 'name' ] ) && $_POST[ 'name' ] != "" ) { $name = $_POST[ 'name' ]; } else { die( "You forgot to fill in your name.\n" ); } // Obtain Quiz Answers $q = array(); $total = 0; for( $x = 1; $x<20; $x++ ) { if( isset( $_POST[ 'Q'.$x ] ) ) { $q[$x] = $_POST[ 'Q'.$x ]; $total += $q[$x]; } else { die( "You forgot to fill in answer: ". $x . "\n" ); } } // Display Results echo( "<p>Hello: " . $name . "<br><br><br>\n" ); if( $total < 21) { echo ('im a little teapot'."<br><br><br><br><br>"); } else if($total < 41) { echo ('im a medium teapot'."<br><br><br><br><br>"); } else if($total < 61) { echo ('im a large teapot'."<br><br><br><br><br>"); } else if($total <= 80 ) { echo ('im a fat teapot'."<br><br><br><br><br>"); } else { echo ('im a jenny craig teapot'."<br><br><br><br>"); } } ?> <HTML> <HEAD> <TITLE> Quiz Results </TITLE> </HEAD> <BODY> <? DisplayQuizResults(); ?> </BODY> </HTML>
  10. try <?php $a = 'sasa xxx'; echo $a,"<br />\n"; $a = preg_replace('/[^;]+;/','',$a); echo $a; ?>
  11. change line for($a=0;$a<=$size;$a++) to for($a=0;$a<=$size2;$a++)
  12. try <?php while($row = mysql_fetch_array($query)) { $supplier = explode("|",$row['supplier']); $tmp_list_suppliers[] = $supplier[0]; // if(!in_array($list_suppliers,$seen) && !in_array($list_suppliers,$multiple)) // { // array_push($seen,$list_suppliers); // } // else // { // array_push($multiple,$list_suppliers); // unset($seen[$list_suppliers]); } $tmp =array_count_values($tmp_list_suppliers); $seen = array_keys($tmp,1); $multiple = array_unique(array_diff($tmp_list_suppliers, $seen)); ?>
  13. i don't real understud what you doing if you just want to extract last part of string try <?php $a = 'consumer electronics|portable audio|mp3 and mp4 players|ipod'; $b = explode('|',$a); echo $numberz = count($b) - 1; echo ' last element is: ',$b[count($b) - 1]; // or //echo $numberz = preg_match_all('/\|/',$a,$b); ?>
  14. <?php $row['description'] = '<blah blah>one<two></two>two'; echo strip_tags($row['description']); // or //echo preg_replace('/<[^>]*>/',' ',$row['description']); ?>
  15. or <?php $a = "The quick brown fox jumps over the lazy dog. "; $a = str_repeat($a, 50); $a = explode(' ', $a); $a = array_chunk($a, 100); foreach ($a as $c) $out[] = implode(' ', $c); print_r($out); ?>
  16. <?php $text = '[img:160:120:ef49b298be]http://i6.photobucket.com/albums/*****/Mystic_Mark/Photo-0119.jpg[/img:ef49b298be]'; $text = preg_replace('#\[(/?)img:.*?\]#si', '[$1img]', $text); echo $text; ?> return [img=http://i6.photobucket.com/albums/*****/Mystic_Mark/Photo-0119.jpg]
  17. <?php $var="http://www.google.com/search?q=Tallahassee+Websites&rls=com.microsoft:*&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1"; $var = parse_url($var); parse_str($var['query'], $out); echo $out['q']; ?>
  18. $text = preg_replace('#\[(/?)img:.*?\]#si', '[$1img]', $text);
  19. remove } in line 11 and line 14
  20. <?php $var="http://www.google.com/search?hl=en&rls=com.microsoft:*&pwst=1&q=tallahassee+web+designer&start=10&sa=N"; parse_str($var, $out); echo $out['q']; ?>
  21. function News() { mysql_close($conn2); require ('multi_operations/config_inc.php'); $query = "SELECT * FROM multi_news WHERE `status`='1' ORDER BY id DESC"; $result = mysql_query($query) or die(mysql_error()); // $row2 = mysql_fetch_array($result); // if ($row2['status'] == '1') { while($row2 = mysql_fetch_array($result)){ echo ' <table width="100%" cellpadding="3" cellspacing="1" border="0" class="bordercolor"> <tr class="titlebg"> <td align="center" colspan="2" class="largetext"><b>'.$row2['subject'].' - '.$row2['date'].'</b></td> </tr> <tr> <td class="windowbg" valign="top" style="padding: 7px;"> <div style="font-size: 0.85em">'.$row2['message'].'</div> </td> </tr> </table> '; } // } mysql_close($conn); }
  22. try <?php $options = array( 9 => array(12, 18, 20), 12 => array(3, 6), 18 => array(19, 13) ); $total_comb = 1; $keys = array(); $key_count = array(); $out = array(); foreach ($options as $k => $v){ $keys[] = $k; $total_comb *= count($v); $key_count[$k] = count($v); } $keys = array_reverse($keys); for ($x = 0; $x < $total_comb; $x++){ $i = $x; $tmp = array(); foreach ($keys as $k){ $a = $i % $key_count[$k]; $i = (int) ($i / $key_count[$k]); $tmp[] = array('option' => $k,'value' => $options[$k][$a]); } $out[] = array_reverse($tmp); } print_r($out); ?>
  23. 1st i see: change line $parent = (isset($_GET['parent'])) : htmlentities(mysql_real_escape_string($_GET['parent'])) ? false; to $parent = (isset($_GET['parent'])) ? htmlentities(mysql_real_escape_string($_GET['parent'])) : false; swap ? and :
  24. you must setup another php file to add property header to your image data
×
×
  • 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.