-
Posts
24,602 -
Joined
-
Last visited
-
Days Won
829
Everything posted by Barand
-
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>'; ?>
-
Not offhand, member. I don't know what your $adjusted array looks like.
-
You need an "ALTER TABLE" query to add the new columns http://dev.mysql.com/doc/refman/5.6/en/alter-table.html
-
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 '+'
-
Select from Database Query not Filtering
Barand replied to MartynLearnsPHP's topic in PHP Coding Help
Your message table does not contain a link to the message it is replying to, so how do expect to count the replies? -
error wont send checkbox value to next page
Barand replied to jamesreno20's topic in PHP Coding Help
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? -
Select from Database Query not Filtering
Barand replied to MartynLearnsPHP's topic in PHP Coding Help
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"? -
Select from Database Query not Filtering
Barand replied to MartynLearnsPHP's topic in PHP Coding Help
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 ..... -
I suggest you check your function showCountryContentInPage()
-
display image from uploaded directory (php mysql)
Barand replied to benidopogi's topic in PHP Coding Help
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? -
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>
-
$tot = 0; while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { .... .... $tot += $row['duration']; // accumulate duration } echo "Total duration: $tot";
-
Merging data from two multidimensional arrays
Barand replied to StevenTompkins's topic in PHP Coding Help
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 -
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.
-
Merging data from two multidimensional arrays
Barand replied to StevenTompkins's topic in PHP Coding Help
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. -
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
-
Which bit of that error message don't you understand?
-
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.
-
can't retrieve values from Multiple selected list
Barand replied to Cyjm1120's topic in PHP Coding Help
You are not echoing the option value Change <?php $existing_mID[$j];?>" > to <?php echo $existing_mID[$j];?>" > -
array_slice doesn't have an "end_point', it has a "start point" and "number of elements"
-
Use natsort(). That will sort as image1, image2, image10 .. etc
-
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
-
1. Don't shout. 2. Use code tags when posting code or use the <> button 3. Try using array_intersect()
-
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