Jump to content

sasa

Staff Alumni
  • Posts

    2,804
  • Joined

  • Last visited

  • Days Won

    1

sasa last won the day on November 28 2014

sasa had the most liked content!

About sasa

  • Birthday 06/01/1963

Profile Information

  • Gender
    Male
  • Location
    Hrvatska

sasa's Achievements

Newbie

Newbie (1/5)

2

Reputation

  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']); ?>
×
×
  • 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.