Jump to content

Barand

Moderators
  • Posts

    24,602
  • Joined

  • Last visited

  • Days Won

    829

Everything posted by Barand

  1. Does this give what you want? <?php // players in order of best to worst $players = array ( 1 => 'Player_1', 'Player_2', 'Player_3', 'Player_4', 'Player_5', 'Player_6', 'Player_7', 'Player_8', 'Player_9', 'Player10', 'Player11', 'Player12', ); // put player12 into an array 12 times, player11 11 times etc $adjusted = array(); foreach ($players as $k=>$p) { $tmp = array_fill(0,$k,$p); $adjusted = array_merge($adjusted, $tmp); } shuffle($adjusted); $adj = array_unique($adjusted); echo '<pre>',print_r($adj, true),'</pre>'; ?>
  2. Not offhand, member. I don't know what your $adjusted array looks like.
  3. You need an "ALTER TABLE" query to add the new columns http://dev.mysql.com/doc/refman/5.6/en/alter-table.html
  4. When you use switch($num) the case values should be possible values of $num eg switch ($dayOfWeek) { case 6: echo "Saturday"; break; case 0: echo "Sunday"; break; default: echo "Weekday"; break; } Alternatively, as in_array() returns true or false, you could switch (true) { case $dow == 6: echo "Saturday"; break; case $dow == 0: echo "Sunday"; break; default: echo "Weekday"; break; } Also, the string concatenation operator in PHP is a period (.) and not '+'
  5. Your message table does not contain a link to the message it is replying to, so how do expect to count the replies?
  6. To expand a variable inside a string the string has to be in double quotes. You have used single quotes. Where is $row defined? Where is that input tag supposed to finish?
  7. Why? You use GROUP BY c.id. If id is unique, and it probably is, then you you get a total count of 1 per id. What are you trying to count in "reps"?
  8. Very confusing SQL queries. When you have a table like your "conversation" table which references two member ids it is usual to connect the member table twice with different aliases and not the conversation table. It is much better to to use explicit join syntax rather then "...FROM A,B,C WHERE...". it is more efficient it separates the structure of the query from the record selection criteria eg SELECT m1.username as user1, m2.username as user2, .... FROM conversation c JOIN member m1 ON c.member1 = m1.id JOIN member m2 ON c.member2 = m2.id WHERE .....
  9. I suggest you check your function showCountryContentInPage()
  10. It may be the relative directory path. You have defined $dir = '/images/advisory'; but in your img tags you use "images/advisory" without the preceding "/". Also, why the <form> tags when you have no form inputs?
  11. Further to my previous post, here is an example using an SVG overlay (assumes your image is "keys.png" and is in the same folder) <?php function segments($cx,$cy,$rad) { $off = 23; $segs = array ( 1 => array($off, -$off), 2 => array(-$off, -$off), 3 => array(-$off, -$off), 4 => array(-$off, $off), 5 => array($off, $off), 6 => array($off, $off) ); $svg=''; $prevtheta = deg2rad(-35); $x1 = $cx + $rad * cos($prevtheta); $y1 = $cy - $rad * sin($prevtheta); $cumval = 0; $vals = array(1=>68,56,56,68,56,56); $total = array_sum($vals); foreach ($vals as $k=>$n) { $cumval += $n; $theta = deg2rad($cumval/$total * 360-35); $x = $cx + $rad * cos($theta); $y = $cy - $rad * sin($theta); $cy1 = $cy + $segs[$k][0]; $cy2 = $cy + $segs[$k][1]; $svg .= "<path class='segment' d='M $cx $cy1 L $x1 $y1 A $rad $rad 0 0 0 $x $y L $cx $cy2 Z' data-segment='$k'/>\n"; $x1 = $x; $y1 = $y; $prevtheta = $theta; } return $svg; } ?> <html> <head> <title>sample</title> <style type="text/css"> .segment { stroke: none; stroke-width: 2px; fill: #eee; fill-opacity: 0; cursor: pointer; } .segment:hover { fill-opacity: 0.1; } #bullseye:hover { fill-opacity: 0.5; fill: #f66; } </style> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type="text/javascript"> $().ready(function() { $(".segment").click(function() { var seg = $(this).data("segment"); // click actions for segments switch (seg) { case 0: alert("Zero"); break; case 1: alert("One"); break; case 2: alert("Two"); break; case 3: alert("Three"); break; case 4: alert("Four"); break; case 5: alert("Five"); break; case 6: alert("Six"); break; } }) }) </script> </head> <body> <div> <svg width='621' height='502' viewBox='0 0 621 502'> <image x="0" y="0" width="621" height="408" xlink:href="keys.png" /> <?=segments(310,191,181)?>; <circle id='bullseye' class='segment' cx="310" cy="191" r="35" data-segment='0' /> </svg> </div> </body> </html>
  12. $tot = 0; while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { .... .... $tot += $row['duration']; // accumulate duration } echo "Total duration: $tot";
  13. Build the first array with the section code as the key, as that is the common element, then add to it instead of building the second array
  14. If you want mouse events and highlighting etc then you you could use that image as a background to an overlaying vector (SVG) image. This allows you you apply ids and classes to the vector objects (circles, circle segments, rectangles etc.) and use javascript as you would on other page elements.
  15. Do those two arrays come from two separate database queries? If so, you could/should use a joined query to get the array you want in the first place.
  16. I suggest you read the example on this page http://php.net/manual/en/features.file-upload.post-method.php and see how the $_FILES should be accessed
  17. Which bit of that error message don't you understand?
  18. Debugging - isn't that what they think we exist for?
  19. With array_intersect() $testTwo = 'bakit ayaw po gumana paulit ulit bakit'; $testOne = 'bakit paulit ulit bakit ulit'; $arr1 = explode(' ', $testTwo); $arr2 = explode(' ', $testOne); $similarities = array_intersect($arr2,$arr1); foreach ($similarities as $s ) echo "$s<br>"; Gives bakit paulit ulit bakit ulit But no way could I get it to output "lang" in the list.
  20. You are not echoing the option value Change <?php $existing_mID[$j];?>" > to <?php echo $existing_mID[$j];?>" >
  21. array_slice doesn't have an "end_point', it has a "start point" and "number of elements"
  22. Use natsort(). That will sort as image1, image2, image10 .. etc
  23. If I format that mess of code from your first post (as you should have done) things become clearer <?php connect_db(); //================================================================================ if(isset($_POST['submit'])=="login"){ $where="( email='".mysql_real_escape_string($_POST["email"])."') and ( password='". mysql_real_escape_string($_POST["password"])."')"; $seldata=$nds->webdreamselect('tbl_users',$where,'','','',''); echo mysql_error(); if(mysql_num_rows($seldata)!=0){ $customer_details=mysql_fetch_array($seldata); echo mysql_error(); $_SESSION["member_id"]=$customer_details["id"]; header("location: home.php"); }else{ $message="Invalid Username / Password Please try again."; } } //================ ?> isset() returns true or false and so will not equal "login". That line should be if(isset($_POST['submit']) && $_POST['submit']=="login") { The code never executes and $message never gets a value, hence your "not defined" message
  24. 1. Don't shout. 2. Use code tags when posting code or use the <> button 3. Try using array_intersect()
  25. example $sql = "SELECT COUNT(*) as tot FROM mytable WHERE data = 'x'"; $res = mysql_query($sql); $row = mysql_fetch_assoc($res); echo $row['tot']; // --> number of records NB: Stop using mysql_xxx functions and change to mysqli_xxx or PDO
×
×
  • 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.