Jump to content

yandoos

Members
  • Posts

    35
  • Joined

  • Last visited

Posts posted by yandoos

  1. <?php
    $per_page='10';
    
    if (isset($_GET['page'])) {
    
    $page = $_GET['page'];
    
    }else {
    
    $page='1';}
    
      // Page will start from 0 and Multiple by Per Page
    $start_from = ($page-1) * $per_page; 
    	 
    	 
    $connection = mysqli_connect($dbhost_name, $username, $password, $database);
     $finder1 = mysqli_query($connection,"SELECT * FROM product left join distribution ON product.pid = distribution.pid
     left join plus_signup ON distribution.mem_id = plus_signup.mem_id LIMIT $start_from, $per_page")  or die (mysql_error());
     
      $connection = mysqli_connect($dbhost_name, $username, $password, $database);
     $counter1 = mysqli_query($connection,"SELECT * FROM product left join distribution ON product.pid = distribution.pid
     left join plus_signup ON distribution.mem_id = plus_signup.mem_id")  or die (mysql_error());
     
      // Count the total records
    $total_records = mysqli_num_rows($counter1);
    
    //Using ceil function to divide the total records on per page
    $total_pages = ceil($total_records / $per_page);
     
     }
    
    echo '<table class="admintable" width="1000" style="padding:0px 10px 0px 10px;" border="0">'; 
    
    
    while($builder1 = mysqli_fetch_array($finder1))
        {    
    
    $pid = mysqli_real_escape_string($connection, $builder1['pid']);
    echo $pid; echo '<br/>';
    
         
        echo'<tr><td valign="top">'; ?>
        
        
        <table border="0"><tr><td width="100">
        <form action="update_image.php" enctype="multipart/form-data" method="post">	
         <input name="pid" type="hidden" value="<?php echo $builder1['pid'];?>">	   
         Name:  </td><td><input name="productname" type="text" value="<?php echo $builder1['productname'];?>"></td></tr><tr>
          <td>Price: </td><td><input name="price" type="text" value="<?php echo $builder1['price'];?>"></td></tr><tr>
          <td> Stock: </td><td><input name="stock" type="text" value="<?php echo $builder1['stock'];?>"></td></tr><tr>
          
          <?php 
          
           
    	  
    	   echo '<tr><td colspan="2">';
    	   
    	   
    	   if ($builder1['name'] != NULL){
    	   
    	    echo 'Product assigned to: <a href="http://dusousbois.co.uk/distributions.php?id=';
    	    echo $builder1['pdid'];
    	    echo '">';
    	    echo $builder1['name'];
    	    echo '</a>';
    	  
    	  
    	   } else if ($builder1['name'] == NULL){
    	   echo 'Product ready for assigment'; 
    	   }
    	   
    	  
    	  
      
    	  
    	  
    	    echo'</td></tr>';
        
          ?>
          
          
          
          
           <td colspan="2">Description:<br/><textarea name="description" cols="40" rows="8"><?php echo $builder1['description'];?></textarea></td></tr><tr>   
           <td><input name="submit" type="Submit" value="Edit Product"/></td>
           
           <td>  <?php if ($builder1['stock'] == '1') {
           echo $pid;
            
    	  echo '<a href="delete_products.php?id=';
    	  echo $builder1['pid'];
    	  
    	  echo'">Delete</a>';
    	  } else if ($builder1['stock'] == '0') {
    	  echo 'This product can not be deleted as it has been assigned to a gallery';
    	  
    	  }  
    	  
    	  echo '</td></tr>';}
    	  
    	  
    	  echo'
    	  </table>'; 
    

    Here is a snipped of the code in question. The problem is that the $pid is not outputting when the mem_id is NULL

  2. Hello I was hoping some help with joining tables....

     

    I have joined tables but have found strange results so i assume I am doing it wrong. Whats happening is that even though I am pulling the query from the product table if there are NULL data in the mem_id field the row is not being pulled. I would add this is using a php while loop, using phpmyadmin and pure mysql it works.

    SELECT * FROM product
    join distribution ON product.pid = distribution.pid
    join plus_signup ON distribution.mem_id = plus_signup.mem_id
    

    Have a look at this phpmyadmin screen shot.

     

     

    The records for pid 3, and 4 are not being outputted when I used a php while loop. I need it so that all the records will be pulled even if the mem_id is null. Is there a way I can do this?

     

    Thank you :)

    post-179293-0-13011100-1438198634_thumb.png

  3. Hello i was really hoping for some help with a select query. Before I explain the issue here is the background.

     

    I have 3 tables - products, clients, distributions

     

    product table

    pid

    productname

    description

    price

     

    client table

    cid

    name

    age

     

    distribution table

    pdid

    pid*

    cid*

    status

    date

     

    I am in the process of building the add distribution form and want to use a select query that will dynamically show the options in a dropdown and  join the 3 tables.

    SELECT name, client.cid FROM distribution join product ON distribution.pid = product.pid
                                      join client ON distribution.cid = client.cid
    
    echo '<option value="'.$build['cid'].'">'.$build['name'].'</option>';
    
    

    Here is the problem... I want ONLY to select the cid and name from the distribution table that has less than 10 records. This is because a client can have only a maximum of 10 distribution records. So I only want these clients to appear as options in the dropdown as opposed to all the clients names and cids. 

     

    I really don't know how to achieve this so any help would be ace.

     

    Thank you

  4. I realised the date needed to be reformatted before it could be updated in the db.

    $pdid = $_POST['pdid']; 
    $delivery_date1 = $_POST['delivery_date'];
    $status = $_POST['status'];
    $start1 = $_POST['start'];
    $ending1 = $_POST['end'];
    $balance = $_POST['balance'];
    
    $delivery_date = date_create($delivery_date1)->format('Y-m-d');
    $start = date_create($start1)->format('Y-m-d');
    $ending = date_create($ending1)->format('Y-m-d');
    

    Thank you :)

  5. if I add $result = mysqli_query($sql); I get an error: Warning: mysqli_query() expects at least 2 parameters, 1 given in /home/dusousbo/public_html/update_distributions.php on line 37
     

    $connection = mysqli_connect($dbhost_name, $username, $password, $database);
    $sql = mysqli_query($connection,"UPDATE distribution SET delivery_date = '$delivery_date', status = '$status', start = '$start', end = '$ending', balance = '$balance' WHERE pdid = '$pdid'" )or die (mysql_error());
    $result = mysqli_query($sql);
    echo $sql;
    echo $result;
    
  6. Thanks for the reply, I've added or die (mysql_error()); to the query and  if I echo $sql; It displays 1.

    $connection = mysqli_connect($dbhost_name, $username, $password, $database)or die('Could not connect: ' . mysqli_connect_error());
    $sql = mysqli_query($connection,"UPDATE distribution SET delivery_date = '$delivery_date', status = '$status', start = '$start', end = '$ending', balance = '$balance' WHERE pdid = '$pdid'" )or die (mysql_error());
    
    echo $sql;
    
  7. I've been staring at this for ages now and just don't see what the problem is. I have an update query that updates records in the db. It only updates some of the fields and ignores all the date fields. I've echoed out variables and they are all correct but they just dont update and there is no error either?

    <?php 
    ini_set('display_errors', 1); 
    error_reporting(E_ALL);
    include "include/session.php";
      require('config.php'); 
      require('include/functions.php'); 
    
      
    
    if (isset($_POST['Submit1'])) { 
    echo 'cheese';
    $pdid = $_POST['pdid']; 
    $delivery_date = $_POST['delivery_date'];
    $status = $_POST['status'];
    $start = $_POST['start'];
    $ending = $_POST['end'];
    $balance = $_POST['balance'];
    }
    
    echo $pdid; echo '<br>';
    echo $delivery_date; echo '<br>';
    echo $status; echo '<br>';
    echo $start; echo '<br>';
    echo $ending; echo '<br>';
    echo $balance; echo '<br>';
    echo $pdid; echo '<br>';
    
    $connection = mysqli_connect($dbhost_name, $username, $password, $database);
    
    
    $result = mysqli_query($connection, "UPDATE distribution SET delivery_date = '$delivery_date', status = '$status', start = '$start', end = '$ending', balance = '$balance' WHERE pdid = '$pdid'");
    
    echo 'done';
    
    
    ?>
    

    What am I doing wrong?

     

    Thanks :(

  8. Hello I'm using a nice datepicker that I want to use on text fields pulled form the database. The things is at the moment only the first row of results (which consists of 3 datepicker fields) actually work with it. I really need to know how to integrate it within the while loop so each row uses the datepicker functionality.

     

    Any chance you can help me please?

    <head>
    <title>Admin Area - Distributions</title>
    <!--[if IE]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
    <link href="css/style.css" rel="stylesheet" type="text/css">
      <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
      <script src="//code.jquery.com/jquery-1.10.2.js"></script>
      <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
      <script>
      $(function() {
        $( "#datepicker" ).datepicker();
      });
      
      
       $(function() {
        $( "#datepicker1" ).datepicker();
      }); 
      
      
        $(function() {
        $( "#datepicker2" ).datepicker();
      }); 
      </script>
    
    </head>
    
     $data = mysqli_query($connection,"
    SELECT name, productname, pdid, description, image1, image2, image3, price, status, delivery_date, start, end, ref, balance FROM distribution join product ON distribution.pid = product.pid
                                      join plus_signup ON distribution.mem_id = plus_signup.mem_id")  or die (mysql_error());
    
    while($build = mysqli_fetch_array($data))
        { ?>
    
    <table><tr><td><form action="update_distributions.php" enctype="multipart/form-data" method="post">
      <input name="pdid" type="hidden" value="<?php echo $build['pdid'];?>" />
      
      Status: </td><td><select name="status">
      <option selected="selected"><?php echo $build['status']; ?></option>
      <option value="Accepted">Accepted</option>
      <option value="Complete">Complete</option>
      <option value="Damaged">Damaged</option>
      <option value="Delivered">Delivered</option>
      <option value="Offered">Offered</option>
      <option value="Sold">Sold</option>  
    </select></td></tr>
    
    
    <tr><td>Balance:</td> <td><input name="balance" type="text" value="<?php echo $build['balance'];?>" /></td></tr>
    <tr><td>Delivery Date:</td> <td><input name="delivery_date" type="text" value="<?php echo $build['delivery_date'];?>" id = "datepicker2" /></td></tr>
    <tr><td>Start Date:</td> <td><input name="start" type="text" value="<?php echo $build['start'];?>" id = "datepicker" /></td></tr>
    <tr><td>End Date:</td> <td> <input name="end" type="text" value="<?php echo $build['end'];?>" id = "datepicker1" /></td></tr>
    <tr><td colspan="2" align="right"><Input type = "Submit" Name = "Submit1"  id="mysubmit" VALUE = "Submit" ></td></tr></table>
    </form> 
    
    <?php } ?>
    

    Thank you

  9. Hello

     

    I'm really not sure what going on but I;m trying to insert a record but it's not working. i just get a white screen. Can you see what the problem is and advise me how to fix it please?

     <form action="add_galleries.php" enctype="multipart/form-data" method="post">		
    <input name="mem_id" type="hidden">
    <input name="userid" type="text">   
    <input name="name" type="text">
    <input name="email" type="text">
    <select name="user_level">
      <option value="0">Regular</option>
      <option value="1">Admin</option>
    </select> 
      
    <input name="pass" type="password">
              
    <input name="submit" type="Submit" value="Add New Gallery"/>
    </form>
    

    and the insert query:

    <?php 
    ini_set('display_errors', 1); 
    error_reporting(E_ALL);
    include "include/session.php";
    require('config.php'); 
    require('include/functions.php'); 
      
    
    if (isset($_POST['submit'])) { 
    
    
    $pass = $_POST['pass'];
    $pass1 = md5($pass);
    
    
    $name = mysqli_real_escape_string(mysqli $link, $_POST['name']);
    $email = mysqli_real_escape_string(mysqli $connection, $_POST['email']);
    $user_level = mysqil_real_escape_string(mysqli $connection, $_POST['user_level']);
    $userid = mysqli_real_escape_string(mysqli $connection, $_POST['userid']);
    $pass2 = mysqli_real_escape_string(mysqli $connection, $_POST['pass1']);
    
    
    echo $name; echo'<br/>';
    echo $userid; echo '<br/>';
    echo $email; echo'<br/>';
    echo $user_level; echo'<br/>';
    echo $pass1; echo'<br/>';
    
    
    $connection = mysqli_connect($dbhost_name, $username, $password, $database);
    $sql = mysqli_query($connection,"INSERT INTO plus_signup (name, userid, user_level, password, email) VALUES ('$name', '$userid', '$user_level', '$pass2', '$email'"); 
    $result = mysqli_query($connection,$sql) or die (mysql_error());
    
    }
    ?>
    
    

    Thank you

  10. The only way I can think of doing this is using the following if else statements but there must be a better way:

    if ($pic == NULL && $pic1 != NULL && $pic2 != NULL) {
    
    } 
    else if ($pic == NULL && $pic1 == NULL && $pic2 != NULL) {
    
    }
    
    else if ($pic == NULL && $pic1 == NULL && $pic2 == NULL) {
    
    }
    else if ($pic != NULL && $pic1 == NULL && $pic2 == NULL) {
    
    }
    
    else if ($pic != NULL && $pic1 != NULL && $pic2 == NULL) {
    
    }
    
    else if ($pic != NULL && $pic1 != NULL && $pic2 != NULL) {
    
    }
    
  11. Hello, I've managed to get it working now - it uploads 3 files and stores the name in the db. There is one problem though if I don't chose an image for 1 of the 3 images then an empty string is updated in the db name and so those image names are lost.

     

    I need to some how find if the file upload is empty and if so not update that image name into the db. I'm really not sure how to do this though. Here is my code:

     <form enctype="multipart/form-data" action="update_image.php" method="POST">
    
    <input name="photo" type="file" style="width:130px; font-size:9px;margin:0px;">   
    <input name="photo1" type="file" style="width:130px; font-size:9px;margin:0px;">
    <input name="photo2" type="file" style="width:130px; font-size:9px;margin:0px;">
    	               
    <input name="pid" type="hidden" value="<?php echo $builder1['pid'];?>">	   
    Name:  <input name="productname" type="text" value="<?php echo $builder1['productname'];?>"><br/>
    Price: <input name="price" type="text" value="<?php echo $builder1['price'];?>"><br/>
    Stock: <input name="stock" type="text" value="<?php echo $builder1['stock'];?>"><br/>
    Description:<br/><textarea name="description" cols="40" rows="8"><?php echo $builder1['description'];?></textarea>    
    
    <input name="submit" type="Submit" value="Edit Product"/>		 
    </form> 
    

    Here is the update_image.php code:

    <?php 
    ini_set('display_errors', 1); 
    error_reporting(E_ALL);
    include "include/session.php";
      require('config.php'); 
      require('include/functions.php'); 
      $email = $_SESSION['mem_id'];
      header("Location: http://myweb.co.uk/products.php");
    
    if (isset($_POST['submit'])) { 
    
    $pid = $_POST['pid']; 
    $productname = $_POST['productname'];
    $description = $_POST['description'];
    $price = $_POST['price'];
    $stock = $_POST['stock'];
    
    $target = "images/";  $target = $target . basename( $_FILES['photo']['name']);
    $target1 = "images/";  $target1 = $target1 . basename( $_FILES['photo1']['name']);
    $target2 = "images/";  $target2 = $target2 . basename( $_FILES['photo2']['name']);
    
    $pic=($_FILES['photo']['name']);
    $pic1=($_FILES['photo1']['name']);
    $pic2=($_FILES['photo2']['name']);
    
    
    $connection = mysqli_connect($dbhost_name, $username, $password, $database);
    $sql = mysqli_query($connection,"UPDATE product SET productname = '$productname', description = '$description', price = '$price', stock = '$stock', image1 = '$pic', image2 = '$pic1', image3 = '$pic2' WHERE pid = '$pid'" ) ; 
    
    $error = false;
    
    if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))  
    {   
    echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";  
    } else $error = true;
    
    if(move_uploaded_file($_FILES['photo1']['tmp_name'], $target1))  
    {   
    echo "The 2 file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";  
    } else $error = true; 
    
    if(move_uploaded_file($_FILES['photo2']['tmp_name'], $target2))  
    {   
    echo "The 3 file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";  
    } else $error = true;
    
    if($error)
       echo "Sorry, there was a problem uploading your file.";
    
      }
    
    ?>
    

    How can I achieve this please???

     

    Thank you :)

  12. Thank you for the info. Just to confirm this does not store the actual image in the db but rather just the name. The actual image is uploaded to a folder on the server and when I select the field I simply point in the location of image and the image name from the db.

     

    I will go through the manual and post my findings.

     

    Thank you very much.

  13. I would add that I can easily change the select query appropriately so that is not the issue:

    mysqli_query($connection,"INSERT INTO product (productname,description,price,image1,image2,image3,stock) VALUES ('".$name."', '".$description."', '".$price."', '".$image1."', '".$image2."', '".$image3."', '".$stock."')") ; 
    mysqli_close($connection);
    
  14. Hello

     

    I really need some help with uploading an image. The name of the image is stored in the appropriate field and the actual image is uploaded to the directory. It works fine at the moment but that is because there is only 1 field in the table for the image. However I now have 3 image fields per record and can't work out how to upload an image to each of these.

     

    So where the table had a field for image it now has image1, image2, image3. I've tried changing the following:

    $fname=($_FILES['photo']['name']);
    
    to
    
    $image1 =($_FILES['photo']['name']);
    $image2 =($_FILES['photo']['name']);
    $image3 =($_FILES['photo']['name']);
    

    But this just seems to conflict and doesnt work.

     

    Any help with this would be great.

     

    Here is my code that works for just a single image.

    <?php 
    require_once 'db_inc.php';
    //This is the directory where images will be saved 
    $target = "product_images/"; 
        if(!is_dir($target)) mkdir($target);
    $target = $target . basename( $_FILES['photo']['name']); 
    
    //This gets all the other information from the form 
    $name=$_POST['name']; 
    $description=$_POST['description']; 
    $price=$_POST['price']; 
    $stock=$_POST['stock']; 
    $fname=($_FILES['photo']['name']); 
    $tmpName  = $_FILES['photo']['tmp_name'];
    $fileSize = $_FILES['photo']['size'];
    $fileType = $_FILES['photo']['type'];
    
    
    
    //process the file
    $fp      = fopen($tmpName, 'r');
    $content = fread($fp, filesize($tmpName));
    $content = addslashes($content);
    fclose($fp);
    
    if(!get_magic_quotes_gpc()){
    $fname = addslashes($fname);}
    
    
    //Writes the information to the database 
    
    mysqli_query($connection,"INSERT INTO product (productname,description,price,image1,stock) VALUES ('".$name."', '".$description."', '".$price."', '".$fname."', '".$stock."')") ; 
    mysqli_close($connection);
     //Writes the photo to the server 
     if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { 
    
     //Tells you if its all ok 
    echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory"; 
           } 
      else { 
    
             //Gives and error if its not 
     echo "Sorry, there was a problem uploading your file."; 
        } 
         ?> 
    

    Thank you

     

  15. I made a mistake and needed to remove the .pdid from

     

    join sold.pdid ON distribution.pdid = sold.pdid

     

    I think perhaps I have the wrong type of join because it is not pulling out all the data in that it pulls the amount of record that are in the sold table. Is there a different join I can use in this scenario?

     

    Thank you
                 

  16. Hello i was hoping for some help please. I have a select that joins 3 tables together (plus_signup, product and distribution) but I need to join another table to it (sold). Every time I try it out in phpmysql I get an error - SELECT command denied to user 'name'@'localhost' for table 'pdid'.

     

    The tables are:

     

    plus_signup

    [mem_id]

    userid

    user_level

    password

     

    product

    [pid]

    productname

    description

    price

     

    distribution

    [pdid]

    pid*

    mem_id*

    status

    start

    end

     

    sold

    [sid]

    pdid*

    qty

    ref

    confirmed

    date

     

    Here is the working SELECT for the 3 tables

    SELECT * FROM distribution join product ON distribution.pid = product.pid
                                      join plus_signup ON distribution.mem_id = plus_signup.mem_id
    					WHERE distribution.mem_id = '4'
    

    Here is what I have tried when adding the fourth table (sold) to it

    SELECT * FROM distribution join product ON distribution.pid = product.pid
                                      join plus_signup ON distribution.mem_id = plus_signup.mem_id
    				  join sold.pdid ON distribution.pdid = sold.pdid
    					WHERE distribution.mem_id = '4'
    

    It's just not working so I'm wondering how to fix it and whats wrong?

    Can you help me please?

     

    Thank you

  17. Thank you very much that's really done it!

     

    So to take this a step further I could add this function to a functions.php file and simply call the function on this page at the top? So I  don't need to have the actual function on the page?

     

    include "include/functions.php";

  18. Ok I will post the code below and attach a screen print so you can see what i am trying to achieve.

    I have a number of records that are displayed with various status. All those records with a status = Delivered the select menu is shown where the user can select the number of items sold. This then updates the database accordingly. I wanted it so each select menu only offers the possible max of the items they have (as detailed in $qty).

     

    Thank you so much, I really appreciate it. :)

    <?php
      
      
      ini_set('display_errors', 1); 
    error_reporting(E_ALL);
    include "include/session.php";
      include('config.php'); 
      $email = $_SESSION['mem_id'];
    
       
    	  
    
    ?>
    <!DOCTYPE html>
    <html>
    <head>
    <title>Members Area</title>
    <link href="css/style.css" rel="stylesheet" type="text/css">
    </head>
    <body>
    
    <p>Welcome! <?php echo $_SESSION['userid']; ?></p>
    
    <?php 
    
    $finder = mysqli_query($connection,"SELECT mem_id, user_level FROM plus_signup WHERE mem_id = '$email'")  or die (mysql_error());
    while($builder = mysqli_fetch_array($finder))
        {   
    	$user =  $builder['mem_id']; 
    	$userlevel =  $builder['user_level']; }
    
    
    $data = mysqli_query($connection,"
    SELECT * FROM distribution join product ON distribution.pid = product.pid
                                      join plus_signup ON distribution.mem_id = plus_signup.mem_id
    					WHERE distribution.mem_id = '$user' AND  NOT distribution.status = 'Rejected' ORDER BY FIELD(status, 'Offered', 'Delivered','Dispatched','Accepted', 'Complete', 'Rejected')")  or die (mysql_error());
    	
    	
    	
    					
    	if($userlevel == '1') { 
    	
    	echo '<div class="admin-controls"> Products | New Clients | Distributions </div> ';
    	}else {
    	echo 'not admin';}				
    					
    					
    								  
    		if(count($data)) {  				  
    echo '<table class="tables" width="100%" border="0">';
    								  
    while($build = mysqli_fetch_array($data))
        {  
    	
    $qty =  $build['qty'];	
    
    $test =  $build['pdid'];
    
    echo'<br/>';
    
    
    	
    if ($build['status'] == 'Offered') {
    echo '<tr><td valign="top" style="border:1px dashed #1fa91f;"><img src="images/1.jpg" style="float:right;"/><p>';
    
    } else { echo '<tr><td valign="top"><img src="images/1.jpg" style="float:right;"/><p>';}
    	
    	
    	
    	echo 'Name:';
    	echo $build['productname']; 
    	echo '</p><p>Description:';
    	echo $build['description']; 
    	echo '</p><p>Price:';
    	echo $build['price'];
    	echo '</p><p>Qty:';
    	echo $build['qty'];
    	
    		
    	if ($build['status'] == 'Offered') {?>
    
    
    <FORM name ="form1" method ="post" action ="accept_order.php">
    <input name="pdid" type="hidden" value="<?php echo $build['pdid'];?>" />
    <input name="pid" type="hidden" value="<?php echo $build['pid'];?>" />
    <input name="qty" type="hidden" value="<?php echo $build['qty'];?>" />
    <input name="stock" type="hidden" value="<?php echo $build['stock'];?>" />
    
    <Input type = "Radio" Name ="order" value= "Accepted" style="width:20px; vertical-align: baseline; margin-top:0px;"><strong>Accept this item?</strong>
    
    <Input type = "Radio" Name ="order" id="radio1" value= "Rejected" style="width:20px; vertical-align: baseline; margin-top:0px;"><strong>Reject this item?</strong>
    
    
    <Input type = "Submit" Name = "Submit1"  id="mysubmit" VALUE = "Submit" >
    
    </FORM>
    
    
    <?php }	
    	
    	else if ($build['status'] == 'Delivered' || $build['status'] == 'Complete')   {
    	
    	
    	
    	echo '</p><p>Status:';
    	echo $build['status']; 
    	
    	echo '</p><p>'; 
    	
    	
    	if ($build['qty'] > 0) { 
    	
    	$connection = mysqli_connect($dbhost_name, $username, $password, $database);
    $sql1 = mysqli_query($connection,"SELECT qty FROM distribution WHERE pdid = '$test' AND status = 'Delivered'" ) ; 
    while($build1 = mysqli_fetch_array($sql1))
        {  
        
        $qty = $build1 ['qty'];
        echo $build1 ['qty'];
        $qtyMax = '1';
        
        }?>
    	
    	<FORM name ="form2" method ="post" action ="item_sold.php">
    <input name="pdid" type="hidden" value="<?php echo $build['pdid'];?>" />
    <input name="pid" type="hidden" value="<?php echo $build['pid'];?>" />
    <input name="qty" type="hidden" value="<?php echo $build['qty'];?>" />
    <input name="stock" type="hidden" value="<?php echo $build['stock'];?>" />
    <input name="price" type="hidden" value="<?php echo $build['price'];?>" />
    <input name="balance" type="hidden" value="<?php echo $build['balance'];?>" />
    
    <?php 
    
     function genQtyList($item_sold, $qtyMax = '$qty', $qtyMin = 1)
    {
        $html = "\n<select name=\"$item_sold\">\n";
    
        for($i = $qtyMin; $i <= $qtyMax; $i++)
            $html .= "\t<option>$i</option>\n";
        $html .= "</select>\n";
    
        return $html;
    }
    
    // pass maximum qty as second argument, generates options 1 to 4
    echo 'Items sold: ' . genQtyList('item_sold', $qty);
    
    
    ?>
    
    <Input type = "Submit" Name = "Submit2"  id="mysubmit" VALUE = "Submit" >
    
    </FORM>	
    	
    	<?php
    	
    	}echo '<p style="color:#d42626;">Balance Owed: £';echo $build['balance'];}
    	
    	else {echo '</p><p>Status:';
    	echo $build['status']; 
    	
    	echo '</p><p>';}
    	 
    	 echo '</td></tr>';			
    	}
    	
    	echo '</table>';
    	} else {echo'No';}		
    	
    	echo '';	
    	?>	
    	
      </body>
      </html>
      
    
    

    print.png

  19. Hello is there away to undeclare this function after? i ask because it is nested between a while loop and for the next record displays an error:  Fatal error: Cannot redeclare genQtyList()

     

    I've tried:

    $declare = function genQtyList($item_sold, $qtyMax = '$qty', $qtyMin = 1)
    {
        $html = "\n<select name=\"$item_sold\">\n";
    
        for($i = $qtyMin; $i <= $qtyMax; $i++)
            $html .= "\t<option>$i</option>\n";
        $html .= "</select>\n";
    
        return $html;
    }
    
    // pass maximum qty as second argument, generates options 1 to 4
    echo 'Items sold: ' . genQtyList('item_sold', $qty);
    
    unset($declare);?>
    

    But i just get a white screen.

×
×
  • 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.