Jump to content

tHud

Members
  • Posts

    93
  • Joined

  • Last visited

Everything posted by tHud

  1. Wow! That certainly does what I want. Thank you However there is a small glitch.... Notice: Uninitialized string offset: 0 in /../info.php on line 137 line #137 equates to the first line of this code chunk... if ($table != $row["table"][0]) { // end the previous table, if any if ($table) { echo "</table>"; } $table = $row["table"][0]; // start the next table echo "<h1>{$table}</h1>"; echo "<table>"; }
  2. err yeah... (You can tell I'm not much good at this can't you...) I've since decided to take your advice and go down the multi-deminsional array method. I got the results into the array by doing this... while($row = mysql_fetch_array($result)) { $results[] = $row; A typical element outputted via print_r looks like this.. [2] => Array ( [0] => 81 [id] => 81 [1] => pongo supplies [company] => pongo supplies [2] => C10 [table] => C10 [3] => 1 [status] => 1 [4] => 0000-00-00 [paid] => 0000-00-00 ) In the example above, the vendor has been assigned Table C10 What I'm not sure about, is.... How could I now create 3 (HTML) tables grouped by element2 'table' where the table groups are A, B or C ? Thanks so much for the help
  3. Hello The exhibitor is assigned an exhibition table. It starts with either A, B or C. (A12, C24 etc.) I'm only using the first letter to decide which array the 'e-table' belongs in. Then I want to add it to its appropriate array for outputting on the screen later. Hope that clears it up. I'm open to all advice.
  4. Hello I have been taking a look at associative arrays. I 'sort' of get the key/value idea, but I'm not quite sure if they appropriate for use with 3 items (as opposed to the 2 key/value items.) In the code below, I can incorporate the 'company' and 'table' values - but I'm not sure how to add the 'id' value (from the query). I would very much appreciate some guidance here. Thank you. $a = array(); // 'A' table array $b = array(); // 'B' table array $c = array(); // 'C' table array $query = "SELECT id, company, `table` FROM EXHIBITORS WHERE year = $year ORDER BY company ASC"; $result = mysql_query($query) or die("There was a problem with the SQL query: " . mysql_error()); if (mysql_num_rows($result) > 0) { while($row = mysql_fetch_array($result)) { $testCol = substr($row['table'], 0, 1); if ($testCol == 'A') { $a[$row['company']] = $row['table']; } else if ($testCol == 'B') { $b[$row['company']] = $row['table']; } else if ($testCol == 'C') { $c[$row['company']] = $row['table']; } } echo "<table>"; foreach($a as $key => $value){ echo "<tr><td>company: $key</td><td>Table: $value </td></tr>"; } echo "</table>"; echo "<table>"; foreach($b as $key => $value){ echo "<tr><td>company: $key</td><td'>Table: $value </td></tr>"; } echo "</table>"; echo "<table>"; foreach($c as $key => $value){ echo "<tr>"<td>company: $key</td><td>Table: $value </td></tr>"; } echo "</table>"; } else { echo "No Exhibitor data for the year $_POST[selectByYear]"; }
  5. oh yeah - that hit the spot! Thank you Buddski!!! Can I be cheeky now and ask if it possible to end the string at the end of a word - and not in mid word as I am currently doing? Thank you :)
  6. Hi Unfortunately not. This is what the output looks like... <div style="padding-bottom: 10px"> <strong><span class="bodyTitle themeColor">Seamless information workflow and dahdah monitoring </span></strong><br /> <br /> dah dah dah
  7. Hello $row[longdescription] contains a description of a product (complete with HTML mark-up). I would like to display the first 250 characters in the results of a search. I would also like to remove any images that may crop up. This is what I have so far... echo strip_tags(html_entity_decode(substr(preg_replace('/<img[^>]*>/Ui', '', $row[longdescription]), 0, 250))); The thing is (as you guys can probably already see), it also counts the HTML mark-up as characters and I get very different outputs (especially if an image occurs). I'd appreciate if you could advise me as to the correct way of doing this. Thank you
  8. Thank you. That works for me.
  9. Hi I am trying to join 3 tables. I think I know why I am getting bad results, but I don't know how to rectify the issue. Here are the tables... Companies comp_id comp_name Orders ord_id comp_id ord_number Invoices inv_id comp_id inv_number I would like to have a table that displays... comp_name -- ord_number -- inv_number I am using comp_id as the common factor, but when I try... companies.comp_id = orders.ord_id and companies.comp_id = invoices.inv_id I get 'odd' results. I think I see why the results are bad, but don't know what to do about it. Any thoughts on what to do please? Thank you
  10. Yes, sorry for not explaining more clearly. The snippet is from a larger program. The original data may have been entered as a TM or 'R' etc. but have been encoded prior to entry into the database.
  11. Thanks. However if I do that, the browser shows this link... DEVICE%C2%AE%201000%20AED.htm but the generated file is... DEVICE® 1000 AED.htm
  12. If I were able/allowed to do that, I would have done so. Any other thoughts, please?
  13. Unable to edit - so I will just mention here that I left .htm out in the echo statement. $pagename.htm It doesn't affect the actual problem. Thanks.
  14. Hi I am using urlencode to create links to pages. It all works well until I come up against 'TradeMark' or 'Registered' etc. The snippet below works up to a point... <?php $pagename = urlencode("Test Device® CR Plus"); touch ("$pagename.htm"); echo "<a href=\"$pagename\">Test Device® CR Plus</a>"; ?> The point being, it creates a file called Test+Device%AE+CR+Plus.htm as you would expect. However, when clicking on that link, I get a 404. I checked in the browser window and in the FTP pane and the file is definitely there. However, when clicking on Test+Device%AE+CR+Plus.htm in a browser file listing, this Test+Device%25AE+CR+Plus.htm is what I see in the browser navigation bar. Any thoughts on how I can get around this? Thanks.
  15. Heh - thanks guys. I actually did consider that but I wasn't sure that the resulting word+word+word format was the 'right' way to do things. Thank you for confirming that.
  16. Hello I would like to convert a database 'product title' field into an URL. The part that I am concerned about is the product title itself. Typically, it would look something like this... Would it be acceptable to simply replace the spaces with underscores? Or should I be looking into removing the ™ and ® (and other characters)? In which case, ideally I would need... ...but I wouldn't have a clue how to capture all such oddities. Is there perhaps a function that 'helps' with this sort of thing? Or is it down to regular expressions only? Thanks for any help
  17. I can't try that on the work server until Monday, but I'm quite sure it will work. Thanks very much (I'll mark SOLVED on Monday )
  18. phpMyAdmin 2.6.0-pl3 MySQL 4.1.22-standard-log Hello I need to generate a report that will only display the latest date that a device was serviced. Each piece of equipment will have several job sheets attached to it but I would like to display only the latest one. For instance, in the list below I would like the monitor & printer to be listed - but also only the pump serviced on 25/12/2010. I'd appreciate if someone could guide me on this Thank you
  19. Brilliant! Thank you so much
  20. Hi I am trying to send a company name to a form for users to report errors. echo "<a href=\"http://www.example.com/suppliers.php?companyName=$compName\">$compName</a>"; In the form, I have the usual code which I use to fill in the value of a field... $companyName = $_REQUEST['companyName']; This works fine - except if there is an ampersand in the name. A & B Products...., becomes just A I have tried htmlentitles to convert to & but the problem still exists. Any thoughts on how I could correct this? Thanks
  21. Maybe something like this? http://silisoftware.com/scripts/?scriptname=backupDB
  22. I don't know why. I guess it's code I routinely paste. However, I knew that I had read something about that in these forums but I was unable to find it due to the search function being unavailable. It clearly shows a fundamental misunderstanding on my part. I won't make that mistake again! Thank you AbraCadaver.
  23. Currently I have 5 entries in my table. Entring this query displays all five in the correct order. SELECT * FROM products ORDER BY count DESC LIMIT 16 However, using this code, the first result is omitted and the last four are displayed. $query="SELECT * FROM products ORDER BY count DESC LIMIT 16"; $result = mysql_query($query); $row = mysql_fetch_array($result); echo '<div>'; while ($row = mysql_fetch_array($result)) { echo '<div>'.$row[product].'</div> <div>'.$row[count].'</div>'; } echo '</div>'; Can someone help me find my error? Thanks
  24. Wow! Thanks - that's totally solved it. I really appreciate the help ...thanks also to David for READONLY
  25. mjdamato, I really appreciate you taking time to reply; also for totally correcting my script. However I'm afraid there are a number of issues. The first 4 fields each add up nicely, but when it gets to the subtotal things sort of go wrong... If the subtotal is 1000 discount 10 (%) vat 17.5 (%) The total comes out at 883 (instead of 1057.50) I have no idea why this is, as the math is correct (having been previously used in a simpler format). The other thing is, that the fields marked disabled = "disabled" don't seem to submit (via php to my MYSQL db) When I removed the disabled = "disabled" - they submit ok - is this normal? Unfortunately, this still doesn't work in Firefox Honestly, I do appreciate the help - I'm not complaining, I would just like to get to the bottom of things. Thanks again. Header... <script type="text/javascript"> function getIntValue(fieldObj) { if(isNaN(parseInt(fieldObj.value))) { fieldObj.value = ''; return 0; } return parseInt(fieldObj.value); } function reCalcType(typeName) { var qty = getIntValue(document.getElementById('credit_'+typeName+'_num')); var amt = getIntValue(document.getElementById('credit_'+typeName+'_val')); document.getElementById('credit_'+typeName+'_tot').value = (amt * qty); reCalcTotal(); return; } function reCalcTotal(fieldObj) { //Calc subtotal var pp_tot = getIntValue(document.getElementById('credit_pp_tot')); var pr_tot = getIntValue(document.getElementById('credit_pr_tot')); var job_tot = getIntValue(document.getElementById('credit_job_tot')); var event_tot = getIntValue(document.getElementById('credit_event_tot')); var subTotal = (pp_tot + pr_tot + job_tot + event_tot); document.getElementById('subtotal').value = subTotal; //Calc total var disc = getIntValue(document.getElementById('discount')); var vat = getIntValue(document.getElementById('vat')); document.getElementById('total').value = (subTotal - (subTotal * (disc/100) * (1+(vat/100)) ) ); // document.getElementById('total').value = disc * subTotal * vat; return; } function tt(fieldObj) { alert(fieldObj.value*2); } </script> Form... <form action="" method="post"> <input type="hidden" name="creditRecordAdded" value="<?php echo $client_id; ?>"> <table border="1" width="100%"> <tr><td width="25%">Order Date <span class="link"><a href="javascript: void(0)"><img src="includes/img/liitlehelp.gif" width="13" height="13" border="0"><span>Please use the format xx/xx/xxxx</span></a></span></td><td><input type="text" name="credit_order_date" size="30"></td></tr> <tr><td>Order Number <span class="link"><a href="javascript: void(0)"><img src="includes/img/liitlehelp.gif" width="13" height="13" border="0"><span><u>Their</u> purchase order number.</span></a></span></td><td><input type="text" name="credit_order_num" size="30"></td></tr> <tr><td>Billing Info <span class="link"><a href="javascript: void(0)"><img src="includes/img/liitlehelp.gif" width="13" height="13" border="0"><span>This information will show up on the invoice.<br><br>i.e.<br>overall package information<br>number of adverts<br>number of press releases etc.</span></a></span></td><td><textarea name="credit_bill_info" cols="50" rows="2"></textarea></td></tr> <tr><td colspan="2"> <table width="98%" align="center" border="1"> <tr><td colspan="4"><b>Package</b></td></tr> <tr> <td colspan="2">Start Date : <input type="text" name="credit_start_date" size="10"></td> <td colspan="2">End Date : <input type="text" name="credit_end_date" size="10"></td> </tr> <tr> <td>PP</td><td><input type="text" name="credit_pp_num" size="4" onChange="reCalcType('pp')"></td> <td>@ <input type="text" name="credit_pp_val" size="10" onChange="reCalcType('pp')"></td> <td> = <input type="text" name="credit_pp_tot" size="10" id="credit_pp_tot" ></td> </tr> <tr> <td>PR</td><td><input type="text" name="credit_pr_num" size="4" onChange="reCalcType('pr')"></td> <td>@ <input type="text" name="credit_pr_val" size="10" onChange="reCalcType('pr')"></td> <td> = <input type="text" name="credit_pr_tot" size="10" id="credit_pr_tot"></td> </tr> <tr> <td>Jobs</td><td><input type="text" name="credit_job_num" size="4" onChange="reCalcType('jobs')"></td> <td>@ <input type="text" name="credit_job_val" size="10" onChange="reCalcType('job')"></td> <td> = <input type="text" name="credit_job_tot" size="10" id="credit_job_tot" disabled="disabled"></td> </tr> <tr> <td>Events</td><td><input type="text" name="credit_event_num" size="4" onChange="reCalcType('event')"></td> <td>@ <input type="text" name="credit_event_val" size="10" onChange="reCalcType('event')"></td> <td> = <input type="text" name="credit_event_tot" size="10" id="credit_event_tot" disabled="disabled"></td> </tr> </table> </td></tr> <tr> <td>Subtotal</td><td><input type="text" name="credit_subtotal" id="subtotal" size="30" onChange="reCalcTotal()" disabled="disabled"></td> </tr> <tr> <td>Discount (%) </td> <td><input type="text" name="credit_discount" id="discount" size="30" onChange="reCalcTotal()"></td> </tr> <tr> <td>VAT (%) </td> <td><input type="text" name="credit_vat" id="vat" size="30" value="17.5" onChange="reCalcTotal()"></td> </tr> <tr> <td>Total </td> <td><input type="text" name="credit_total" id="total" size="30" disabled="disabled"></td> </tr> <tr><td>Invoice Date</td><td><input type="text" name="credit_inv_date" size="30"></td></tr> <tr><td>Invoice Number <span class="link"><a href="javascript: void(0)"><img src="includes/img/liitlehelp.gif" width="13" height="13" border="0"><span>Adding an invoice number here - makes the invoice active.<br><br>i.e. This record will now be removed from the <i>Orders that have not been invoiced</i> screen.</span></a></span></td><td><input type="text" name="credit_inv_no" size="30"></td></tr> <tr><td>Paid Date</td><td><input type="text" name="credit_paid_date" size="30"></td></tr> <tr><td>Contact <span class="link"><a href="javascript: void(0)"><img src="includes/img/liitlehelp.gif" width="13" height="13" border="0"><span>This is the name that will appear above the company address details on the invoice.</span></a></span></td><td><input type="text" name="credit_contact" size="30"></td></tr> <tr><td>Contact Number</td><td><input type="text" name="credit_contact_num" size="30"></td></tr> <tr><td>Contacted On</td><td><input type="text" name="credit_contacted" size="30"></td></tr> <tr><td>Notes <span class="link"><a href="javascript: void(0)"><img src="includes/img/liitlehelp.gif" width="13" height="13" border="0"><span>These are for personal use and do not appear on the invoice.</span></a></span></td><td><textarea name="credit_notes" cols="40" rows="5"></textarea></td></tr> <tr><td colspan="2" align="center"><input type="submit" value="Add a new credit record"></td></tr> </table></form>
×
×
  • 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.