Jump to content


  • Content count

  • Joined

  • Last visited

  1. Hello Guys, Am developing a matches permutation betting App/Calculator in PHP. The user will have to enter the 2 possible outcomes on each match (win or not win) and combine as many matches as possible. Also will enter amount per bet (eg $10). Then the app will print out possible outcomes of the matches. I have form fields as below; I know this is a multidimensional array. The above give 8 ways of combinations. I want to collect these detail and convert them to a multidimensional array like below; $play = array ( 'Game 1' => array(1.75, 2.25), 'Game 2' => array(1.20, 3.50), 'Game 3' => array(2.50, 4.10) ); I got several php permutation functions like below; function permutations(array $array) { switch (count($array)) { case 1: return $array[0]; break; case 0: throw new InvalidArgumentException('Requires at least one array'); break; } $a = array_shift($array); $b = permutations($array); $return = array(); foreach ($a as $key => $v) { if(is_numeric($v)) { foreach ($b as $key2 => $v2) { $return[] = array_merge(array($v), (array) $v2); } } } return $return; } $combos = permutations($play); echo '<pre>'; print_r($combos); Show result has MY QUESTIONS ARE 1) Is there anyway i can make it to show as 2) Is it possible to have d multiplication of all the odds multiplied by the amount in an array (1.75 * 1.2 * 2.5 * 10 = 52.5) as below; 3) I want array with the least multiplication be echo out anywhere on the page. Are these possible? If the function above is not the best, it there any better one? Thanks ahead.
  2. Hello there, I have an online store,where the members can subscribe to any of the 3 packages (1, 2 & 3). Below is a sample of the Products DB table. id package product status 1 3 Biro 1 2 1 Paper 1 3 3 Pin 0 4 2 Eraser 1 5 2 Blade 1 6 3 Bag 1 7 2 Pen 0 8 1 Sharpener 1 9 1 Shoe 1 10 2 Chair 1 I displayed the package 3 products first, then package 2 products next then package 1 products last like this; $get_products = mysql_query("SELECT * FROM products WHERE status='1' ORDER BY package DESC"); But what i want to really do is to randomly display all package 3 products first, then randomly display package 2 products and lastly display package 1 products randomly. So that no particular item will always be at the top while some will always be on the bottom. How do I write the syntax. Thanks in advance
  3. Hello, I am using OO prepared statement. I need to count the number of rows returned and echo out the rows. But the problem is that i can only echo $stmt->num_row only if I include $stmt->store_result(). But if I include $stmt->store_result(), i can't echo out the rows. Below is my script. //THIS WILL ECHO THE num_rows BUT WILL NOT ECHO THE DATA FROM THE DB TABLE $get_user = $conn->prepare("SELECT * FROM realtors_admins WHERE realtor=? ORDER BY unik DESC"); $get_user->bind_param('s', $remail); $get_user->execute(); $get_user->store_result(); $result = $get_user->get_result(); echo $get_user->num_rows."."; while ($row = $result->fetch_assoc()) { echo .$row['fname']." ".$row['lname']; } //THIS WILL NOT ECHO num_rows BUT WILL ECHO THE DATA FROM THE DB TABLE $get_user = $dWay->prepare("SELECT * FROM realtors_admins WHERE realtor=? ORDER BY unik DESC"); $get_user->bind_param('s', $remail); $get_user->execute(); $result = $get_user->get_result(); echo $get_user->num_rows."."; while ($row = $result->fetch_assoc()) { echo .$row['fname']." ".$row['lname']; } Also when can one use $stmt->fetch() and $stmt->fetch_assoc() ? Thanks
  4. Wow, like magic. It works. I was on this for more than an hour. Thanks greatly BrowerBugs
  5. Hello, I have a login page and I am trying to use the input username & password to confirm member. Below is my code but it is not echoing the name out. $uname = $_POST[username]; $pword = $_POST[password]: $get = $dWay->prepare(SELECT firstname, lastname, city FROM members WHERE username=? AND password=?); $get->bind_param('s, s', $uname, $pword); $get->execute(); $get->bind_result($fname, $lname, $city); $get->fetch(); echo $fname; If I use one parameter like in below code, It will echo out the name. But I must use two (username & password) parameter $get = $dWay->prepare(SELECT firstname, lastname, city FROM members WHERE username=?); $get->bind_param('s', $uname); //OR $get = $dWay->prepare(SELECT firstname, lastname, city FROM members WHERE password=?); $get->bind_param('s', $pword); Please what could be the problem, because I must use both Email & Password to confirm each member. Thanks
  6. How to pass a php variable to a popup window

    Thanks Nillervision & rbrtsmith, @ Nillervision: That's not even the problem because it's not affecting it. @ rbrtsmith: am not opening another window, what i meant was modal. Pls am not advance in modal & ajax. can you please put me through how to go about that.
  7. Hello, I am working on an online store. Each product has QUICK VIEW link which popup the product detail in a popup window. But am finding it difficult to make the popup show the detail of the particular product clicked. Below are my codes. $get_items = mysqli_query($my_link, "SELECT * FROM $table ORDER BY id DESC); while($row=mysqli_fetch_array($get_items)){ $id = stripslashes($row[id]); $category = stripslashes($row[category]); $type = stripslashes($row[type]); $product = stripslashes($row[name]); echo "<a href='detail.php?id=$id'>".$product."</a>"; echo $category <a class="preview" href="#product-preview" data-toggle="modal" ></a> } /* I REPLACED <a class="preview" href="#product-preview" data-toggle="modal" ></a> WITH <a class="preview" href="id=$id#product-preview" data-toggle="modal" ></a> AND ALSO <a class="preview" href="#product-preview&id=$id" data-toggle="modal" ></a> BUT DIDN'T WORK */ Below is my popup code <?php $id = $_GET[id]; $get = mysqli_query($my_link, "SELECT * from products WHERE id='$id'"); $row = mysqli_fetch_array($get); $id = stripslashes($row[id]); $category = stripslashes($row[category]); $product = stripslashes($row[name]); ?> <div class="modal fade" id="product-preview" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content space-40"> <a aria-hidden="true" data-dismiss="modal" class="sb-close-btn close fa fa-times" href="#"></a> <!--<button aria-hidden="true" data-dismiss="modal" class="close sb-close-btn" type="button"><i class="fa fa-times"></i></button>--> <!-- Single Products Start --> <div class="clearfix"></div> <section id="product-fullwidth" class="clearfix"> <div class="single-product-wrap"> <div class="list-category-details"> <div class="col-md-7 col-sm-7"> <!-- Main Slider Start --> <section id="main-slider1" class="carousel slide main-slider"> <!--Carousel Slide Button Start--> <div class="slider-pagination col-md-2 col-sm-3 col-xs-3"> <ul class="product-thumbnails"> <li data-slide-to="0" data-target="#main-slider1"> <a href="#"><img class="img-responsive" alt="img" src="assets/img/product/single-thumb1.png"></a></li> <li class="active" data-slide-to="1" data-target="#main-slider1"> <a href="#"><img class="img-responsive" alt="img" src="assets/img/product/single-thumb2.png"></a></li> <li data-slide-to="2" data-target="#main-slider1"> <a href="#"><img class="img-responsive" alt="img" src="assets/img/product/single-thumb3.png"></a></li> <li data-slide-to="3" data-target="#main-slider1"> <a href="#"><img class="img-responsive" alt="img" src="assets/img/product/single-thumb4.png"></a></li> </ul> </div> <div class="col-md-10 col-sm-9 col-xs-9"> <div class="carousel-inner product-fullwidth light-bg slider"> <div class="item"> <img src="assets/img/product/single-prod1.png" alt="..."> </div> <div class="item active"> <img src="assets/img/product/single-prod1.png" alt="..."> </div> <div class="item"> <img src="assets/img/product/single-prod1.png" alt="..."> </div> <div class="item"> <img src="assets/img/product/single-prod1.png" alt="..."> </div> </div> </div> </section> <!-- / Main Slider Ends --> </div> <div class="col-md-5 col-sm-5"> <div class="product-content"> <div class="rating"> <span class="star active"></span> <span class="star active"></span> <span class="star active"></span> <span class="star half"></span> <span class="star"></span> <div class="product-review"> <ul> <li>03 Review </li> <li> | <a href="#"> Add Your Review </a> </li> </ul> </div> </div> <div class="product-name"> <a href="#"><?php echo $product; ?></a> </div> <div class="product-price"> <h4 class="pink-btn-small price-line"> $50.00 </h4> <h4 class="blue-btn-small"> $45.00 </h4> </div> <div class="product-availability"> <ul class="stock-detail"> <li>Available:<strong class="green-color"> <i class="fa fa-check-circle"></i> In Stock </strong> | </li> <li>Product Id:<?php echo $_GET[pid]; ?><strong> #201546 </strong> </li> </ul> <hr class="fullwidth-divider"> </div> <div class="product-size"> <form class="product-form"> <div class="row"> <div class="form-group selectpicker-wrapper"> <label>SIZE</label> <select title="Looking to Buy" data-toggle="tooltip" data-width="100%" data-live-search="true" class="selectpicker input-price bs-select-hidden"><option class="bs-title-option" value="">2 - 4 Years</option> <option>4 - 6 Years</option> <option>6 - 8 Years</option> <option>8 - 10 Years</option> </select> </div> <div class="form-group selectpicker-wrapper"> <label>QTY</label> <select title="Looking to Buy" data-toggle="tooltip" data-width="100%" data-live-search="true" class="selectpicker input-price bs-select-hidden"><option class="bs-title-option" value="">02</option> <option>03</option> <option>04</option> <option>05</option> </select> </div> </div> </form> <div class="widget-colors"> <span>Colors:</span> <label class="rcheckbox-inline"><input type="checkbox" value="" id="brown"> <span></span></label> <label class="rcheckbox-inline"><input type="checkbox" value="" id="light"> <span></span></label> <label class="rcheckbox-inline"><input type="checkbox" value="" id="dark"> <span></span></label> <label class="rcheckbox-inline"><input type="checkbox" value="" id="orange"> <span></span></label> <label class="rcheckbox-inline"><input type="checkbox" value="" id="blue"> <span></span></label> <label class="rcheckbox-inline"><input type="checkbox" value="" id="yellow"> <span></span></label> <label class="rcheckbox-inline"><input type="checkbox" value="" id="green"> <span></span></label> <label class="rcheckbox-inline"><input type="checkbox" value="" id="white"> <span></span></label> </div> <hr class="fullwidth-divider"> </div> <div class="add-to-cart"> <a class="blue-btn btn" href="#"> <i class="fa fa-shopping-cart white-color"></i> Add to Cart</a> <a class="pink-btn btn" href="product-single-fullwidth.html"> Go To Details </a> </div> </div> </div> </div> </div> </section> <!-- Single Products Ends --> </div> </div> </div>
  8. Thanks all, I really appreciate you. let me try this last solution. Thanks a lot
  9. Thanks Friend, I have sorted it out
  10. Thanls nahosting, Am not really cleared, can you please white out the syntax for me? Thanks grately.
  11. Thanks Nock, i tried it but still get the same result. Below is my new code $DB_NAME = ''; $DB_HOST = 'localhost'; $DB_USER = 'root'; $DB_PASS = ''; $mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME); $get_emails = mysqli_query($mysqli, "SELECT email FROM customers"); $all_emails = array(); while($row = mysqli_fetch_array($get_emails)){ $all_emails[] = $row[email]; } foreach($all_emails as $to_email){ $send1 = mail($to_email, $sub, nl2br($msg), $headers); }
  12. Hello Friends, I have a products table with several columns. On my Home page I want to display 30 items at random but all new Items to come first. Below are the codes I tried. $sql = mysql_query("SELECT * FROM products WHERE status='Online' && nature='Yes' ORDER BY RAND() LIMIT 5"); //FOR ONLY NEW ITEMS $sql = mysql_query("SELECT * FROM products WHERE status='Online' && nature!='Yes' ORDER BY RAND() LIMIT 35"); //FOR OTHER ITEMS How do I make them into one line. Thanks
  13. Hello Friend, I tried sending mail to the 30 email addresses in mysql table with the below code. But the problem am having is that, the code is sending the same mail to all the emails 30 times. $get_emails = mysql_query("SELECT email FROM customers"); while($row = mysql_fetch_array($get_emails)){ $email = $row[email]; mail($email, $sub, nl2br($message), $headers); } I also tried something like this but still gave the same result. $get_emails = mysql_query("SELECT email FROM customers"); $all_emails = array(); while($row = mysql_fetch_array($get_emails)){ $all_emails[] = $row[email]; } foreach($all_emails as $to_email){ mail($to_email, $sub, nl2br($message), $headers); } } Pls what's the way out Thanks
  14. Hello friends, I want to search keywords from 2 tables. I have tries some queries but were not working. I have broken down my keywords into an array as below. $keywords = $_GET[q]; $kt=split(" ",$keywords);//Breaking the string to array of words // Now let us generate the sql while(list($key,$val)=each($kt)){ if($val<>" " and strlen($val) > 0){$q .= " name like '%$val%' or ";} } $q=substr($q,0,(strLen($q)-3)); I have 2 tables CARDS TABLE id name size price 1 Love & Hate A3 50 2 I am in Love A4 80 3 In the Blues A4 80 GIFTS TABLE id name price 1 cups and spoon 65 2 love mug 33 3 Hi bee 20 Now if I search for "hi love", it should show me FROM CARDS TABLE 1 Love & Hate A3 50 2 I am in Love A4 80 FROM GIFTS TABLE 2 love mug 33 3 Hi bee 20 pls how do query the tables Thanks
  15. Thanks Privileged, will give it a try