Jump to content

richrock

Members
  • Posts

    213
  • Joined

  • Last visited

Posts posted by richrock

  1. Right - got the select to show if the item is locked, now I've just gotta figure out how to show the form element when a locked sale is selected.  I've made it a bit obvious at the moment to show which sale is locked...

     

        <?php
            // FIXME - add selection of option if sale locked.
            
        ?>
    	<td>Sale Number: <?php echo $rcatinfo; ?></td>
    	<td>
                <select name="salenum" onchange="">
    		<!--<option value='none'>-- Select A Sale --</option>-->
    			<?php
        				do {
    						if ($rcatinfo==$row_selectsalenum['id']) {
    							echo "<option  value ='".$row_selectsalenum['id']."' selected>".$row_selectsalenum['id']." - ".$row_selectsalenum['catname']." - ".$row_selectsalenum['locked'];
                                    if ($row_selectsalenum['locked'] == 1) {
                                        echo "LOCKED";
                                    }
                                    echo "</option>\n";
    						} else {
    							echo "<option value ='".$row_selectsalenum['id']."'>".$row_selectsalenum['id']." - ".$row_selectsalenum['catname']." - ".$row_selectsalenum['locked'];
                                    if ($row_selectsalenum['locked'] == 1) {
                                        echo "LOCKED";
                                    }
    
                                    echo "</option>\n";
    						}
    
    					} while ($row_selectsalenum = mysql_fetch_assoc($resultsalenum));
    
    						$rows = mysql_num_rows($resultsalenum);
    						if($rows > 0) {
    						mysql_data_seek($resultname, 0);
    						$row_selectsalenum = mysql_fetch_assoc($resultsalenum);
    
    						}
    			?>
    	</select>
    	</td>
    </tr>
    <?php
      if ($sale_locked == 1) {
          echo "<tr><td colspan='2'>";
          echo "<span style='color:#ff0000'>This sale has been sent to publication as a catalogue.</span>";
          echo "</td></tr>";
          echo "<tr><td>";
          echo "Assigned Lot Number: ";
          echo "</td><td>";
          echo "<input type='text' name='wibble' value='".$rlot_num."' readonly size='10' />";
          echo "</td></tr>";
          // FIXME - add feature for when adding the lots to consignment, if it's a locked sale.
    
      }
    
    
    ?>

     

    See also attached image for output.  I'd like the extra form to appear directly below this select....  ???  Thanks

     

    [attachment deleted by admin]

  2. Hi,

     

    Sorry for the delay in replying - caught a nice bout of flu over the weekend, so I'm a little behind on work :(

     

    First, you're saying simply that when someone selects a locked item from the select list, you want something to pop down near it, allowing an override?  What type of thing needs to appear.. where.. etc?

     

    Exactly.  I want a checkbox and a text input box.  These will appear directly below the select, and I can separate the tables up if necessary.  Unfortunately, the code is for a private adminisatration project, so it's not on the web as such.

     

    I just don't understand enough about Javascript to know how to make a form element 'appear'.

     

    Going back to your sample, I assume I am right in adding the 'locked' element like this:

     

    <tr>
          <td>Sale Number: <?php echo $rcatinfo; ?></td>
          <td>
                <select name="salenum" onchange="show.hiddenForm(locked)">
             <!--<option value='none'>-- Select A Sale --</option>-->
                <?php
                   do {
    
                         if ($rcatinfo==$row_selectsalenum['id']) {
                            echo "<option  value ='".$row_selectsalenum['id']."' selected";
      if($row['isLocked'] == 1){
        echo 'locked="true"'. //etc etc
    }
    echo ">".$row_selectsalenum['id']." - ".$row_selectsalenum['catname']."</option>\n";
                         } else {
                            echo "<option value ='".$row_selectsalenum['id']."'";
      if($row['isLocked'] == 1){
        echo 'locked="true"'. //etc etc
    }
    echo ">".$row_selectsalenum['id']." - ".$row_selectsalenum['catname']."</option>\n";
                         }
    
                      } while ($row_selectsalenum = mysql_fetch_assoc($resultsalenum));
    
                         $rows = mysql_num_rows($resultsalenum);
                         if($rows > 0) {
                         mysql_data_seek($resultname, 0);
                         $row_selectsalenum = mysql_fetch_assoc($resultsalenum);
    
                         }
                ?>
          </select>
          </td>
    </tr>

     

    Yeah?

     

    Thanks for understanding.

  3. Hi,

     

    I'm creating a form in which I need to do the following:

     

    I have a select box in which I have some sale categories.  Some of these categories are 'locked', in other words, no more items should be added to that sale.

     

    I need to create an 'override' section to the form to expand if a locked sale is selected, without reloading the page (complications due to POST).  Having no clue about ajax, and having trawled the web for the last couple of days, I need some help!!

     

    Here is the php code on which I need to base this:

     

    <tr>
    	<td>Sale Number: <?php echo $rcatinfo; ?></td>
    	<td>
                <select name="salenum">
    		<!--<option value='none'>-- Select A Sale --</option>-->
    			<?php
    				do {
    
    						if ($rcatinfo==$row_selectsalenum['id']) {
    							echo "<option  value ='".$row_selectsalenum['id']."' selected>".$row_selectsalenum['id']." - ".$row_selectsalenum['catname']."</option>\n";
    						} else {
    							echo "<option value ='".$row_selectsalenum['id']."'>".$row_selectsalenum['id']." - ".$row_selectsalenum['catname']."</option>\n";
    						}
    
    					} while ($row_selectsalenum = mysql_fetch_assoc($resultsalenum));
    
    						$rows = mysql_num_rows($resultsalenum);
    						if($rows > 0) {
    						mysql_data_seek($resultname, 0);
    						$row_selectsalenum = mysql_fetch_assoc($resultsalenum);
    
    						}
    			?>
    	</select>
    	</td>
    </tr>

     

    I have set up a 'locked' column in the table and can add this to the select list, but am stuck as to how to proceed in order to create a form (which isn't a problem) if the category is locked...

     

    Any ideas would be appreciated.

     

    TIA

  4. many thanks!  It seems I'll have to do some research on the isset() and empty() to help improve the code speed, although that's not a great issue here, as the script's only going to be used by a maximum of four people ever, and seems plenty fast enough (just basic form handling for names & addresses)...

     

    Thanks again all!  ;D

  5. I've been using php error reporting to refine some code I've written.  I've checked out the manual, and am currently using

    error_reporting(E_ALL)

    but this throws up a lot of Undefined Index errors, most of which I know about, and as it's a multifunction page, I don't really need to deal with.

     

    Being the relative n00b at PHP, and never having used error_reporting, how could I use it to report all errors 'except' this undefined index?

  6. Hi,

     

    I'm trying to create a form.  The first page shows a list of customers, amounts to invoice, etc.  These link to a detailed page listing full customer details, items purchased and requiring invoicing.

     

    Now...

     

    I need the save button on this detailed page to :

     

    a: link back to the original list updated with remaining customers not invoiced.

    (This is ok, I can do this bit on it's own)

    b: also run a php script that generates a pdf, emails it to the customer and vendor, and saves a backup copy.

    (This is also ok on it's own)

     

    Problem is I can't figure how to link to both the pdf script (inv_book.php) and the original list (inv_admin.php)

     

    Any ideas on this would be greatly appreciated...  My initial thought was to link back to the original list, and add a function at the start to run the PDF script.  Is this the right approach?

  7. Hi,

     

    Been scratching my head over this for a while now.

     

    I have two tables, one purchases, the other won items.  Both have invoice numbers attached to the items in each table, which may (or may not) be unique to each table... eg

     

    purchasesinvoicenumwon itemsinvoicenum

    Item 1INV-001Won Item 1INV-001

    Item 2INV-002Won Item 2INV-003

     

    And so on.

     

    In order to find all distinct Invoices in both tables, I need to join the tables, and find all DISTINCT() invoice numbers.

     

    I've never seen any LEFT JOIN query using more than one DISTINCT statement, so can it be done?  Or am I going completely the wrong way?

     

    My thinking is (poor code follows):

     

    SELECT DISTINCT(inv_num) as invoices FROM purchases LEFT JOIN won_items ON inv_num GROUP BY purchases.invoices ORDER BY invoices DESC

     

    But this is wrong, so....  ???

     

    TIA

  8. Thanks man, well appreciated.  For some bizarre reason, the editor had loaded up an older file from the sub-folder, so any edits weren't affecting the proper file.

     

    Silly me.  :-[

     

    Thanks again!

     

    BTW - I'd placed thos sillyvals to check what $_POST variables were being sent.  This script has become quite confusing for me  :-[

  9. Okay, I'm still a bit new at this, and can't see the wood for the trees, so to speak.

     

    In my editor, line 636 is:

     

    if ($_POST['meh']) {

     

    and the block around that is:

     

    <tr>
            <td valign="top"><?php echo LOT_st_price; ?> </td>
            <td valign="top"><input name='pricestart' type='text' size='50' value='<?php
            if ($_POST['meh']) {
                echo $rstprice;
            }
            ?>' </td>
        </tr>

    (lines 633-640 inclusive)

     

    I see an error and have changed to enclose the <input> statement:

     

    <tr>
            <td valign="top"><?php echo LOT_st_price; ?> </td>
            <td valign="top"><input name='pricestart' type='text' size='50' value='<?php
            if ($_POST['meh']) {
                echo $rstprice;
            } ?>' /></td>
        </tr>

     

    Which to me now reads absolutely correct.  The statements above and below are in the same format too.  I still have the error at line 636, and also doesn't explain why when I have an empty php file called instruments.php the error still exists...

     

    (btw - I apologise if this sounds a bit shirty/cocky, it's not mean't to be - I'm really appreciative of your help here)

  10. There's 920 lines of code, are you sure???? Ah, I'll attach the file :)

     

    Please don't mock the code, it's a bit of a mess too.  It's part of an admin panel for administering, and will be password protected later on.

     

    Modified - 920 lines not 9202 as mentioned earlier

     

    [attachment deleted by admin]

  11. Hi,

     

    I'm using Wamp 2.0, and I've got a problem with a stuck page.

     

    I have various buttons that link to an instruments.php page, and I've done something that causes this error:

    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in D:\Documents\wamp\www\auctionsys\administration\instruments.php on line 636

     

    even if I clear the cache, restart WAMP, empty the php file to an emtpy document, the error still appears....  Help!!!  :o

     

    I've read up on the error, I understand what the error means, but even removing the block of code around the 636 mark does not change the line number in the error or even remove the error itself...

     

  12. Hi all,

     

    I'm trying to retrieve information in a single mysql command to generate information for a pdf file.  This requires a total list of items in a sale, and also displayed alongside will be offers made prior the sale.

     

    I have two tables, one has around 200 items, called bid_auctions, and the other called bids.  bid_auctions has an entry called bid_offer, and simply indicates 0 or 1, depending on whether the item has (1) or hasn't (0) had a bid placed on it.  the second table (bids) has information such as bid_amount, bid_id (the id number from bid_auctions).

     

    I need to list all items, and if they have a bid, list that info too.  I can't seem to find any info about joining where there is an 'if' statement, eg join bids if bid.id_offer = bid_auctions.id....

     

    Help  :-[

     

    Update: I've found that I can do if in mysql, however, can't figure out how to do an if.. join statement...

  13. The form field is like this:

     

    <td><input type="text" maxlength="2" name="day" size="1"/> - <input type="text" maxlength="2" name="month" size="1" /> - <input type="text" maxlength="4" name="year" size="3" /> <?php echo SALE_add_date_details; ?></td>

    And when the form is submitted, it sends to a function - addSale (), which has the original code I posted earlier.

     

    I get what you mean with an array - I am forcing the end user to input 2 numbers, so August would always be 08 - would this be reflected in the array by doing:

     

    08 => "August",

     

    ??

  14. Hi all,

     

    I've written a basic conversion script to change a numerical value entered into a form to a calendar month, ie - 05 = May.

     

    Here's the code:

     

    if ($_POST['month'] == 01) {
    		$month = "January";
    	} elseif ($_POST['month'] == 02) {
    		$month = "February";
    	} elseif ($_POST['month'] == 03) {
    		$month = "March";
    	} elseif ($_POST['month'] == 04) {
    		$month = "April";
    	} elseif ($_POST['month'] == 05) {
    		$month = "May";
    	} elseif ($_POST['month'] == 06) {
    		$month = "June";
    	} elseif ($_POST['month'] == 07) {
    		$month = "July";
    	} elseif ($_POST['month'] == 08) {
    		$month = "August";
    	} elseif ($_POST['month'] == 09) {
    		$month = "September";
    	} elseif ($_POST['month'] == 10) {
    		$month = "October";
    	} elseif ($_POST['month'] == 11) {
    		$month = "November";
    	} elseif ($_POST['month'] == 12) {
    		$month = "December";
    	}
    
    	echo $month."<br />";
    
    	$cat_title = $_POST['saletitle'];
    	$cat_day = $_POST['day'];
    	$cat_mon = $_POST['month'];
    	$cat_year = $_POST['year'];
    	$cat_salenum = $_POST['salenum'];

     

    But for some really strange reason, it stops working for August, September and I can't for the life of me figure out why...  Any ideas?  All the code was cut'n'pasted so it should work consistently right?

  15. Hi,

     

    maybe I've done this the wrong way, but I've displayed the list of categories available by using the while loop:

     

    		while ($row = mysql_fetch_assoc($rSaleList)) {
    
    		echo "<input type='hidden' value='".$row['id']."' name='".$row['id']."' />";
    		echo "<tr>\n";
    		echo "<td width='65'>\n";
    		echo "<input type='text' value='".$row['id']."' READONLY />";
    		echo "</td>\n";
    		echo "<td width='140'>\n";
    		echo "<input type='text' name='day' value='".$row['day']."' size='1' maxlength='2' />-<input type='text' name='month' value='".$row['month']."' size='1' maxlength='2' />-<input type='text' name='year' value='".$row['year']."' size='3' maxlength='4' />";
    		echo "</td>\n";			
    		echo "<td width='275'>\n";
    		echo "<input type='text' name='catname' value='".$row['catname']."' size='45' />";
    		//echo $row['catname'];
    		echo "</td>\n";
    		echo "<td width='50'>\n";
    		echo "<input type='checkbox' name='published' value='".$row['id']."' ";
    		if ($row['active'] == 1) {
    			echo "checked='yes'";
    		}
    		echo "/>";
    		echo "</td>\n";
    
    		echo "</tr>\n";
    
    	}

     

    Which displays the categories, and all the information readily available in each input box.  However, when I submit the form, I don't get all the information from each form element in POST.  That's OK, because I expected that. 

     

    So now I need to get each row of categories into the POST statement to process them.  Now I've figure this may need something like explode() but unfortunately I'm a bit of a n00b still (getting there tho) - so if anyone has any pointers how to adjust this code to be able to insert into the DB afterwards.  (That bit should be fine, it's just the sending/receiving via POST)...

     

  16. I figured this out.  I had changed the table in the database, and could group by different results to get the right answer. 

     

    Regarding auto_increment - I mentioned that there are already a number of pre-existing receipt numbers, many of which are not in the database, hence the need to manually add numbers as clients place new orders, and generate new ones for new clients.  It was an initial thought of mine too.

  17. Hi,

     

    In theory, I know why my command isn't returning the required result.  I have a php function that selects a maximum receipt number, then adds +1 to create a new number.  The system is written like this so that numbers can be manually added (another  feature).

     

    However, my command:

     

    SELECT MAX(receipt_num) FROM receipts;

     

    Gives me a result of 89.  The largest number in the column is 1047.  Part of the reasoning is this is a transfer system, and the receipt numbers added afterwards may already exist (hence the manual addition) otherwise going from the top.

     

    So why does the command not give me 1047?  It's an INT(4) if that's any help...

     

    Rich

  18. ,

     

    Having a little difficulty in displaying modified dates on a page - they're all stuck at 1970 and all the tutorials I find just talk about using date() without the results of a mysql query.

     

    Hi $getBids = "SELECT * FROM jos_bids ORDER BY id_offer ASC";
    $resBids = mysql_query($getBids) or die(mysql_error());
    
    // generate the rows
    
    	while ($row_bids = mysql_fetch_array($resBids)) {
    
    		$id_offer = $row_bids['id_offer'];
    		$userid = $row_bids['userid'];
    		$bid_price = $row_bids['bid_price'];
    		$date_placed = date("d.m.Y",$row_bids['modified']);
    		$time_placed = date("H.i.s",$row_bids['modified']);
    

     

    As you can see, I've placed the date in the while function.  However, when I echo $date_placed and $time_placed, I get 01.01.1970, and 01.33.28 respectively.  How do I get the actual real dates displayed?

  19. I've got my script working perfect to upload files.  However, almost everything I see is about uploading images, which is probably the most common use for this function.

     

    However, I need to upload the following: .doc, .pdf, .wav, .mpg and .wmv

     

    I've found the mimetype for pdf - 'application/pdf', but can't seem to find the other formats.

     

    Just got to fill in the gaps here:

     

    // allow MIME file types
    $filetype = array('application/pdf','','','');
    $ftype = false;
    
    // check if uploaded file type is allowed
    foreach($filetype as $type) {
    
    if ($type == $_FILES['frmfile']['type']) {
    
    	$ftype = true;
    	break;
    
    }
    
    }

     

     

  20. Hi all,

     

    Driven myself nuts doing a percentage results for a poll embedded on a page.

     

    I've copied the code for each of the 8 pages that have individual polls, and I'm not sure how to locate the problem - below is one of the pages:

     

    <?php
    
    $query = mysql_query("SELECT * FROM `poll` ORDER BY `id` DESC LIMIT 1");
    $rows = mysql_num_rows($query);
    
    if($rows > 0){
    	$poll = mysql_fetch_array($query);
    	$title = $poll['name'];
    } else {
    	$title = 'No Poll Yet';
    }
    
    $query = mysql_query("SELECT `questions`.`pid` FROM  `responses`, `questions` WHERE `responses`.`qid`=`questions`.`id` AND `responses`.`ip`='".$_SERVER['REMOTE_ADDR']."' AND pid='".$poll['id']."'");
    
    if(mysql_num_rows($query) > 0){
    $total = mysql_query("SELECT `questions`.`pid` FROM  `responses`, `questions` WHERE `responses`.`qid`=`questions`.`id` AND pid='".$poll['id']."'");
    $total = mysql_num_rows($total);
    ?>
    <table width="208" cellpadding="0" cellspacing="0" border="0" class="maintable" align="left">
    <tr>
    	<td valign="top" align="center" class="title"><p class="question"><?php echo $title; ?></p></td>
    </tr>
    <?php
    	$query = mysql_query("SELECT * FROM `questions` WHERE `pid`='".$poll['id']."' ORDER BY `question`");
    	$questions = mysql_num_rows($query);
    	if($questions > 0){
    ?>
    <tr>
    	<td valign="top" style="padding: 5px;">
    	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="question">
    		<?php
    			while($question = mysql_fetch_array($query)){
    				$responses = mysql_query("SELECT count(id) as total FROM `responses` WHERE qid='".$question['id']."'");
    				$responses = mysql_fetch_array($responses);
    				echo $responses;
    				$percentage = round(($responses['total'] / $total) * 100);
    				$percentage2 = 100 - $percentage;
    		?>
    			<tr>
    				<td valign="top" nowrap="nowrap"><p class="question"><?php echo $question['question']; ?></p></td>
    				<td valign="top" height="10" width="100%" style="padding: 0px 10px;">
    				<table width="100%" cellpadding="0" cellspacing="0" border="0">
    					<tr>
    						<td valign="top" width="<?php echo $percentage; ?>%" <?php if($percentage > 0){?>style="background: url('images/bar.jpg') repeat-x;"<?php } ?>><img src="images/dot.gif" width="1" height="19" /></td>
    						<td valign="top" width="<?php echo $percentage2; ?>%"></td>
    					</tr>
    				</table>
    				</td>
    				<td valign="top"><?php echo $responses['total']; ?></td>
    			</tr>
    		<?php
    		}
    		?>
    		<tr>
    			<td valign="top" colspan="3" align="center" style="padding: 10px 0px 0px 0px;">Total Votes: <?php echo $total; ?></td>
    		</tr>
    	</table>
    	</td>
    </tr>
    <?php
    	}
    ?>
    </table>
    <?php
    } else {
    ?>
    <table width="300" cellpadding="0" cellspacing="0" border="0" class="maintable" align="center">
    <tr>
    	<td valign="top" align="center" class="title"><?php echo $title; ?></td>
    </tr>
    <?php
    	$query = mysql_query("SELECT * FROM `questions` WHERE `pid`='".$poll['id']."' ORDER BY `question`");
    	$questions = mysql_num_rows($query);
    	if($questions > 0){
    ?>
    <tr>
    	<td valign="top" style="padding: 5px;">
    	<form name="poll" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="question">
    	<?php
    		if(isset($error)){
    	?>
    		<tr>
    			<td valign="top" colspan="2" align="center" style="padding: 0px 0px 10px 0px;"><?php echo $error; ?></td>
    		</tr>
    	<?php
    		}
    	?>
    		<?php
    			while($question = mysql_fetch_array($query)){
    		?>
    			<tr>
    				<td valign="top" style="padding: 0px 10px 0px 0px;"><input type="radio" name="questions" value="<?php echo $question['id']; ?>" /></td>
    				<td valign="top" width="100%"><?php echo $question['question']; ?></td>
    			</tr>
    		<?php
    		}
    		?>
    		<tr>
    			<td valign="top" colspan="2" align="center" style="padding: 10px 0px 0px 0px;"><input type="submit" name="vote" value="Submit Vote" /></td>
    		</tr>
    	</table>
    	</form>
    	</td>
    </tr>
    <?php
    	}
    ?>
    </table>
    <?php
    }
    ?>

     

    You can see the polls in action at http://www.lifeexpo-co.uk/adults-line.html (and all sub pages in Children and Adult sections.  If you do a couple of polls, you can see the percentages don't add up - 1 page has results in the region of 125%, another has a total of around 80%. 

     

    Any ideas why?  BTW - code wasn't mine, but came from a free resource.

  21. How would I get the results found (like on the CLI) to display on a webpage?  I'm looking at something similar to Google's results page, eg

     

    Results 1 - 10 of about 31,400,000 for goog. (0.07 seconds)

     

    Any ideas?

     

    And sorry - not sure if this was a php or mysql question...

     

    Rich

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