Php check all records in database then display results based on chosen record

I have a form that is checking the database to see if a record exists .
If it does exist then it needs to perform one of two tasks, either subtract or multiple.
This part is working but the part that is not working is it is only checking the first record of the database and it should be checking all records as each record will give a different result
the sql is
mysql_select_db($database_lotties, $lotties);
$query_rsVoucher = "SELECT * FROM LOTTIE_vouchercode";
$rsVoucher = mysql_query($query_rsVoucher, $lotties) or die(mysql_error());
$row_rsVoucher = mysql_fetch_assoc($rsVoucher);
$totalRows_rsVoucher = mysql_num_rows($rsVoucher);
// then check
if (isset($_POST['vouchCode']) && $_POST['vouchCode'] == $row_rsVoucher['VCode']) {
  $mycode = $row_rsVoucher['VCode'];
  $spos = strpos($mycode, "f");
  if ($spos !== false) {
    $myvalue = substr($mycode, $spos+1);
    $myvalue = $XCart_sumTotal * $myvalue / 100;
  } else {
    $spos = strpos($mycode, "p");
    if ($spos !== false) {
      $myvalue = substr($mycode, $spos+1);
  $myTotal = $XCart_sumTotal - $myvalue;
  $_SESSION['vouchCode'] = $myvalue;
} else unset($_SESSION['vouchCode']);
the form is
<form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
<input type="text" name="vouchCode" value="<?php echo @$_POST['vouchCode']; ?>" size="32" />
<input type="submit" value="update" />
</form>
then the results are displayed
<?php if (isset($myvalue)) { ?>
<?php echo DoFormatCurrency($myvalue, 2, ',', '.', '£ ', ''); ?>
<?php } ?>
i am getting really desperate with this so any help would be appreciated
thanks

Jonathan Fortis wrote:
>>You really should hire someone to write your server side code as you still don't understand programming basics.
i did but he passed away. And i am getting an understanding just still cant get the hang of loops
jonathan, jonathan, jonathan,
Condolences to your deceased php developer. Was he the only professional php developer in the world? I don't think so! Enough with your excuses already. Find a professional php developer that is currecntly living then and stop looking for free professional work for your specific, profitable development requirements on a forum.
best,
Shocker

Similar Messages

  • Connect SharePoint to SQL Server Database Then Build Rules Based Returns System

    Hello Guys,
    I work for an ecommerce business. We sell a wide range of products to customers all around the world which are ordered from our websites and then dispatched to our customers from our warehouses.
    I have been tasked with developing a computerised return system from the company because at the moment everything is done using paper forms.
    We have all our customer, order and product data within SQL Server databases.
    What I would like to know is...
    1. Can we connect sharepoint online to a local sql server database
    2. Could we then build searches within sharepoint to display data contained within these databases e.g. customer information etc
    3. How is the data presented in sharepoint - is there a way to design how the data is displayed within sharepoint etc?
    4. Can we then build a rules based return system within sharepoint? The on screen workflow would need to vary according to data contained within the database e.g. the weight if the product being returned and also on fields input by the service agent such
    as the reason for the return, what solution the customer would like etc.
    5. is it possible to build these workflows in such a way that they can be saved part way through then gone back to later
    6. Can reports be build based on the returns that are being generated e.g. list of products most commonly returned
    Sorry for all the questions, I am a bit of sharepoint novice. I think it may possible be able to do what we need but I just wondered if the answer to any of the above questions is definately a no because if it is that could mean it is not suitable
    Thanks

    You could use a BCS connection
    http://community.office365.com/en-us/b/office_365_community_blog/archive/2012/10/11/business-data-connectivity-services-in-office-365-sharepoint-online.aspx, this will allow you to edit data in your non SharePoint SQL DB, on premises, from Office 365 SharePoint.
    Search will index the web applications you point it at, and the lists from the BCS will be part of those web apps, site collections, sites at some place and will get indexed. 
    You can create views on the data, that can sort of work like a search, but when you search on the site where the lists are the query will return results based on the BCS data.
    These views can be based on criteria such as the weight of the product being returned and other fields.
    The data is presented as a list.
    You can make it read only or read-write based on SharePoint permissions on the list.  The account used to create the connection can edit.
    BCS is possible in on-premises SharePoint too
    here is a good read on it,
    http://www.dotnetcurry.com/showarticle.aspx?ID=632
    Stacy Simpkins | MCSE SharePoint | www.sharepointpapa.com

  • Display Results Based On Comparison to Input Values

    Hello,
    I have a utility that is built as a package and allows a user to input either a sku or sku description and receive inventory data (in number format). The utility implicity includes wild card searches and, as a result, may return multiple rows of data to the user.
    Currently there are only the two input fields as described above. I want to add another input field allowing the user to indicate the quantity they are needing of the given part.
    I would like to change my code so that instead of displaying a number value for the available quantity of each given part, it instead does a comparison between the quantity the user inputs as needing and the quantity currently available - and then returns a text message indicating the number of days the product will be available.
    My package accesses a view that contains all of the part information and the current available quantity. I want to take the user inputted required quantity and compare it to the available quantity obtained from the view and then display one of three different text messages depending on how the two values compare.
    What is my best course of action to change from displaying a specific available quantity and instead doing my comparison and displaying a text message as indicated?
    Thank you.

    Assuming that p_desired is the quantity required, then I would probably do a query something like:
    SELECT CASE WHEN avail - p_desired <= 0 THEN 'Sorry, out of luck'
                WHEN avail - p_desired > 0 and <=10 THEN 'You have a day or so'
                ELSE 'You can wait a while' END msg
    FROM view
    WHERE <conditions>You would, of course, implement your own rules in the CASE statement.
    John

  • How to create a program to find files then display results to be clickable?

    Hello,
    I am trying to find files based on extension name. It searches through all child folders from the parent folder to find files.
    This program example, Dupe File Finder shows "Name, Path, and Size" as results. This looks like a JTable without gridlines?
    http://www.softpicks.net/screenshots/Dupe-File-Finder.gif
    Files from the results will be opened differently when double clicked based on their extensions (.java, .jar. .bat. .vow). EX, .java extension opens in Firefox that displays clear text.
    Jtable Component:
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    All I can find is JTable class. I do not think JTable has the best tools to do this. What's your advice related to this program?
    Once I finish this program, I intend to make it find duplicate contents in excel files through the parent folder. Then it displays the list of duplicate files. Importing excel files in the mysql database might get the job done, but I still need to create a graphical user interface.
    Any help would be appreciated.

    This looks like a JTable without gridlines?right.
    All I can find is JTable class. I do not think JTable has the best tools to do this. What's your advice related to this program?JTable has all the facilities which you can think of e.g. the first column in the shown table has a checkbox, this is also possible using JTable, you can set different CellRenderers and CellEditors to customize the table (carry on reading the tutorial, you will find it all there). I would suggest go ahead with JTable.
    Thanks!

  • Check boxes and ok button and displayed results, oh my!

    In a forms page, I have a report.
    I like to put check boxes next to the rows.
    Then when I click on an OK button it will display what I checked off, possibly on this same page.
    How do I create this concerted effect?

    Apex_item.checkbox will let you manually create check box. If it's a tabular form, you can add a row selector.
    e.g
    SELECT APEX_ITEM.CHECKBOX (30,
    NULL,
    NULL,
    'F30_' || LPAD (ROWNUM, 4, '0')
    )delete_checkbox FROM DUAL;
    You can only see the values where items are checked. So you may want to develop some logic to find out rows where items are not checked. Something similar to this
    FOR this IN 1 .. apex_application.g_f30.COUNT
    loop
    display(these values are checked);
    end loop;
    rest of the rows are unchecked.
    --Manish                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Displaying items based on Query record count (Forms 4.5)

    I have a special requirement.
    Assume col1 that I am selecting from table temp.
    select col1 from temp;
    Now if query fetches 9 records.
    Each column I want to show like this.
    1 2 3 4 5 6
    7 8 9
    If query fetches 15 records.
    Each column I want to show like this.
    1 2 3 4 5 6
    7 8 9 10 11 12
    13 14 15.
    That means items displayed on screen chages based on output of
    query.
    Pls. suggest some solution.
    null

    When i made the above query a view and created an oracle portal form. I get this error when I try to retrieve all the records in that view i made above.
    An unexpected error occurred: ORA-01445: cannot select ROWID from a join view without a key-preserved table (WWV-16016)
    What does the "key-preserved table" mean?

  • How to call a stored to search database then return results to jsp page

    Hi,
    Most of what i have said is in the title. Im trying to search a database using a stored procedure that will call the procedure using sql2000 then coming back with the results to the jsp page. all of this is done using JSP web pages. if JAVA example is availabel then let me know.
    I need some examples.. I cant seem to find any code that will help.
    Thanks

    Make use of Callablestatement. You can set parameters to it by registerOutParameters and setXXX methods. And use getXXX methods to get results of procedure.

  • Pulling a Record set and then using a field within that record to pull additional information from the table.

    I am pulling information based on the following "If" statement;
    If({JCT_CURRENT__TRANSACTION.Category} = "L"
        and "cost" in {JCT_CURRENT__TRANSACTION.Transaction_Type}
        and {JCT_CURRENT__TRANSACTION.Transaction_Date} > {@Prev Week}
        and {JCT_CURRENT__TRANSACTION.Transaction_Date} <= {@Week 1})
    then
    {JCT_CURRENT__TRANSACTION.Units}
    This works fine and I can print it on the report with other associated fields.  One of those fields is a "Cost Code" field associated with the above conditions and date set (I am pulling for one pay period week).  Of these transactions, each week different "cost codes" could be available.
    One item I need to figure out another formula is associated with the cost codes that are pulled, but, I need to compare them to a different date range.
    Here is how I get the cost codes that were used in a specific time frame;
    If({JCT_CURRENT__TRANSACTION.Category} = "L"
        and "cost" in {JCT_CURRENT__TRANSACTION.Transaction_Type}
        and {JCT_CURRENT__TRANSACTION.Transaction_Date} > {@Prev Week}
        and {JCT_CURRENT__TRANSACTION.Transaction_Date} <= {@Week 1})
    then
    left({JCM_MASTER__COST_CODE.Cost_Code},6) & "001"
    This gives me the cost codes used in that period but changes the last three digits to be "001" (xx-xx-001).
    Now, I need to take that cost code, the xx-xx-001 and compare it to a completely different date range to get an "estimate" number.
    My problem is that, because I need to use a date range in the original conditions, even after I truncate the cost code, for some reason, it stays associated with that date range.
    How can I use a field from a group of records based on date, but, associate it with a competely different date range.
    I hope this is clear, I am having a real hard time with this, I am fairly new, but have pretty normal working knowledge of basic formulas, etc...
    Thanks, Mike

    Please re-post if this is still an issue

  • Displaying items based on Query record count

    I have a special requirement.
    Assume col1 that I am selecting from table temp.
    select col1 from temp;
    Now if query fetches 9 records.
    Each column I want to show like this.
    1 2 3 4 5 6
    7 8 9
    If query fetches 15 records.
    Each column I want to show like this.
    1 2 3 4 5 6
    7 8 9 10 11 12
    13 14 15.
    That means items displayed on screen chages based on output of
    query.
    Pls. suggest some solution.
    null

    You can't do this with the custom search portlet.
    You can use Omniportlet to display the items - using the SQL datasource (new in the July PDK) to query the content repository views. You could use the parameter form portlet provided with Omniportlet to build the selection list.
    Regards,
    Jerry
    PortalPM

  • The only way my voiceover plays is if I record a dummy; then, it will play the second recording. If I deleted the dummy, no sound. Help!

    I seriously don't know why this is happening. Sometimes I need to record like three before it finally plays.

    Sounds like you need to make a trip to the Genius Bar and get your phone evaluated.

  • Display result based on Financial Quarter

    Hi all,
    I need to display my report based on financial quarter wise(apr-mar) rather calendar year quarter(jan-dec).
    The available dates are calmonth, calquarter(jan-dec).
    Can any one guide me how to derive or define the financial quarter.
    thanks in adv...
    Kiran

    Have a look at previous post:
    Can fiscal month replace quarter?
    See How-To-Guide
    https://service.sap.com/~sapdownload/011000358700002762582003E/HowToDeriveVariableValue.pdf
    for a good example of how to implement Customer-Extis.
    (It's a 2.x Guide but still valid for 3.x)
    Hope this helps.
    Regards

  • Fetching record from table and displaying in JSP while loading page -struts

    Hi all,
    I have a problem relating to struts .
    I am fetching records from database and I want to diaplay those records in corresponding fields in the jsp page.
    I am using Struts MVC Framework.
    I am giving the sample code below.
    In my action class i am giving the following code.
    String sql="Select empname from emp where empcode='1' ";
    ResultSet rs=S.executeQuery(sql);
    if(rs.next()){
    EditForm e=new EditForm();
    e.setEmpname(rs.getString(1));
    In my Action Form
    I gave setter and getter methods for Empname
    public String getEmpname() {
    return empname;
    public void setEmpname(String empname) {
    this.empname = empname;
    In my jsp gave
    <html:form method="POST" action="submitForm.do?action=1" >
    <html:text property="empname" />
    </html:form>
    The targets given are correct and it is being redirected.
    But the value is not displaying in the textbox while the jsp is loading.
    There is a record for the sql query.
    Anybody please help me out
    It is very urgent
    Thank You
    Parvathy

    Now in the following code, why are u creating a new form?
    Why dont you use the form which is input to the Action Class's execute methof?
    if(rs.next()){
    EditForm e=new EditForm();
    e.setEmpname(rs.getString(1));
    }Thanks and regards,
    Pazhanikanthan. P

  • The calendar sync is recently not working correctly, not display "All events" but it only displays the last six months for my individual entries. My repeating entires do go back further, though. How do I fix?

    I have an iPad 5.1.1. The calendar sync has started to not work correctly. I have it checked "All events," but it only displays the last two months for my individual entries. My repeating entires do go back further, though. How do I fix?

    HI Jason269. Thanks for your reply, however I wrote that I already have "All events" checked. If All Events is checked and it doesn't diaplay all events, how do I fix? It seems this is a common issue, as I have read many others on here state the same problem.
    I believe my problem occurred when I synced my iMac calendar to my iPad calendar using yahoo. Yesterday, I unsynced them on my iMac controls. When I checked my iPad calendar, all of my old entries reappeared - but only for five seconds and disappeared again. So, the data is saved and still there but cannot be displayed, even when I have All events checked. In fact, it only shows my individual entries for the last two months, but does show all my recurring entries. If I switched to last six months, I will see everything for the last six months. If I switch back to all events, it is only for the last two months.
    As I mentioned, others on here have expressed exactly the same issue, including the two month example and having used yahoo.
    For legal purposes, I need to be able to use the information from my indidual calendar entries in an upcoming court case. So I really need to fix this ASAP!

  • Display records from database table

    My database table has 495K records i want to display them all in se11 tcode and than download into excel ...but because of huge records it timeout.
    Do I need to write a program for this?
    Or is there any other smarter way.
    Regards,
    DNP

    Hi,
    Please follow the steps below:
    1. Go to the selection screen of SE11 and provide your selection criteria (if required).
    2. Click on Settings menu->User parameters->ALV Grid display.
    3. Now click on Program menu->Execute in background->Provide output device name as LP01 or LOCAL or any valid printer parameters->Click continue->Click Immediate button->Click Save.
    4. You can see the background job for this in SM37.
    5. Once the background job is completed, it will appear in gleen color.
    6. Click on the completed job and then click on Spool button.
    7. Once the output is displayed in spool you can now easily download it to excel by clicking on System menu->List->Save->Local File.
    Hope this will help you.
    Regards,
    Venkat

  • Php (skip to next record in database)?

    Is there a function in php that will skip to the next record in a database and return it to the page if the one its looping through is out of date?
    Here is my senario.
    I have 30 events in a database starting from January 10th 2012 through to December 20th 2012 listed by date - 2012-01-10, 2012-12-20 etc
    On the websites home page I want to list the 3  'next' dates. Obviously January 10th has expired but is still listed in the database. The easiest option would be to delete the record from the data base I guess but was wondering if I can automate the process?
    I can list the 3 dates starting with record one in the database with DW proprietary php code:
    <?php do { ?>
    <div class="event">
    <?php
    echo $row_rsEvents['event_date']."<br />";
    echo $row_rsEvents['event_title'],"<br />";
    echo $row_rsEvents['event_details'];
    ?>
    </div><!-- end event -->
    <?php } while ($row_rsEvents = mysql_fetch_assoc($rsEvents)); ?>
    I can hide an expired date by comparing the date in the database with the current date
    <?php
    $date = date('Y-m-d');
    ?>
    <?php do { ?>
    <div class="event" <?php if($date > $row_rsEvents['event_date']) { echo " style='display: none;'"; }?>>
    <?php
    echo $row_rsEvents['event_date']."<br />";
    echo $row_rsEvents['event_title'],"<br />";
    echo $row_rsEvents['event_details'];
    ?>
    </div><!-- end event -->
    <?php } while ($row_rsEvents = mysql_fetch_assoc($rsEvents)); ?>
    However that then just shows 2 dates as the code still loops through the records from the start of the database.
    Any ideas or pointers?
    Os

    Murray *ACP* wrote:
    You could also do it like this -
    <?php do {
    if(!$date > $row_rsEvents['event_date']) { ?>
    <div class="event">
    <?php
    echo $row_rsEvents['event_date']."<br />";
    echo $row_rsEvents['event_title'],"<br />";
    echo $row_rsEvents['event_details'];
    ?>
    </div><!-- end event -->
    <?php } // end if ?>
    <?php } while ($row_rsEvents = mysql_fetch_assoc($rsEvents)); ?>
    When the date is not greater than the event date, the loop just falls through to the next fetch.
    That just seems to kill any output. I tried a few loops within loops yesterday but could never stop the expired date from being selected for the database. First solution appears to have done the trick so I'm happy.

Maybe you are looking for

  • In Acrobat Professional 8, what is the best way to insert/combine multiple pdf's together in a large

    In Acrobat Professional 8, what is the best way to insert/combine multiple pdf's together in a large volume? We have 300 pdf reports and need to insert a 2 page cover page infront of each report. Not sure if Batch processing is best??? Thanks for any

  • How do I uninstall my Adobe Creative Suite(Windows version) and then reinstall it?

    I am having problem opening any of the programs. Each program that click on to open gives me the same error message: "Adobe Application Manager is needed to resolve this problem. However, it is missing or damaged. Please download and install a new co

  • Terrible dl speeds

    Kind of getting fed up now, I either have really slow speeds or inconsistent connection. I am a heavy user, with playing games online and streaming movies and tv, so I pay for unlimited up to 20mb bb. Its not like I expect 20mb bb, but a little bit o

  • Monthly Sales Report

    Hi All! Is there any kind of report in SAP B1 that shows comparison of monthly sales year over year by state.  So, for example, CA sales Jan-Dec 07 vs. Jan-Dec 08?  Thanks, Mike

  • Auth_check --- FM

    How to find the autho object for the particular field? for eg: p0002-begda. for the particular user i want to restrict the download for single field, How I can differentiate between the 2 users. wt's use of CALL 'AUTH_CHECK