Jump to content

phppup

Members
  • Posts

    741
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by phppup

  1. Thanks KICKEN.

    I came up with something similar at 2:AM this morning, which uses Javascript in a shoddy kinda way, but looked as if it would get the job done.

    This seems like an excellent alternative to weigh in contention, and looks as if it too, would do EXACTLY what I am attempting to accomplish.

    Thanks again.

  2. Or perhaps I am misunderstanding.

    When the link states: 

    If the string is empty, the browser will create a new window every time

    are the statement meant to indicate "... Everytime that a singular new window is opened" but that once opened, it will forever be pointed to until closed?

    Or does everytime meet my goal, which is to open a new window everytime a submit button is clicked???

    So confused now.

     

  3. I've read the link.

    It seems to indicate in the first section that leaving the windowName empty will cause new windows to be opened, yet that does not seem to be the case.

    is this bc I'm using chrome at the moment (I would think not).

    so what am I doing wrong?

    I've read the link.

    It seems to indicate in the first section that leaving the windowName empty will cause new windows to be opened, yet that does not seem to be the case.

    is this bc I'm using chrome at the moment (I would think not).

    so what am I doing wrong?

  4. I seem to be getting an acceptable result, sort of.

    I believe at this point the problem is more with the "target" because I on placing results for submitting 1,2, or 3 on the same target.

    If I submit with button 1, a valid result opens in a new window. If I then submit with button 2, the SAME "new window" repopulates and updates with data associated to that query.

    I am currently unable to get a second "new window" to open for a side by side comparison of on screen data.

    I was thinking of using JS to alter the name of the "target" so I could hopefully evade the conflict in that manner.

    But not having much luck there either.

     

  5. I have a form  with three submit buttons that ALL have the same action="process. php"

    Each submit has a different value to query a database table which provides the requested information.

    Button 1 value = baseball team

    Button 2 value = football team

    Button 3 value = hockey team

    Currently, a submission will process and provide information of the team members for the sport that is selected.

    I have decided it might be nice to retrieve the data in separate windows for easy side by side comparison.

    Using<form action="process. php"  onsubmit="window.open('about:blank','print_popup','width=1000,height=800');"> 

    I have been able to get data to populate in a newly opened window. But the data continues to re-populate the same window.

    How can I get 3 independent NEW WINDOW to open so they can be compared side by side?
     

     

     

     

     

  6. The data is in a simple table with a column for carrots which received a numeric value of the amount that was ordered.  The table is populated by a form submission.

    I think that is what you are asking me.

    I do not have access to my code right now, but will try altering the quotes suggested by gw1500se.

    Any additional guidance is welcome.

  7. The data is in $mytable input into a column named carrots.

    My output was

    There were 3 orders for carrots for 1 lbs. each
    There were 2 orders for carrots for 2 lbs. each
    There were 1 orders for carrots for 3 lbs. each

    but after altering the WHILE STATEMENT it became

    There were  orders for carrots for  lbs. each
    There were  orders for carrots for  lbs. each
    There were  orders for carrots for  lbs. each

    which removed the data information.

    Does something special or unique to MySQLi need to be done to change the hardcoded word "carrots" to the variable $item within that statement?

  8. It was:

    $query = "SELECT carrots, COUNT(carrots) FROM $mytable WHERE carrots>0 GROUP BY carrots ORDER BY carrots ASC"; 
    	 
    $result = mysqli_query($link, $query) or die(mysqli_error());

    Until I changed all the CARROTS to $item.

    The loss of values did not occur until I altered the while statement.

  9. I am UPGRADING some old files to MySQLi and while doing so have decided to complete some leftover projects.

    In this project, I was counting vegetables sold to customers that displayed a report displaying information like this:

    There were 3 orders for carrots for 1 lbs. each
    There were 2 orders for carrots for 2 lbs. each
    There were 1 orders for carrots for 3 lbs. each

    The code I used to generate the messages was:

    while($row = mysqli_fetch_array($result)){
    	echo "There were ". $row['COUNT(carrots)'] ." orders for carrots for ". $row['carrots'] ." lbs. each <br />";
    }

    At the time, I was going to call a separate script for carrots, potatoes, and celery.

    Now, with my worldly advancement (or maybe not.. LOL) I realize I should be able to use the same single script and assign a variable to accommodate each vegetable item.

    After declaring the $item = 'carrots'   I inserted it to test my theory.  I tested the output in stages and all seemed okay until I did this:

    while($row = mysqli_fetch_array($result)){
    	echo "There were ". $row['COUNT($item)'] ." orders for carrots for ". $row['$item'] ." lbs. each <br />";
    }

    Is there an issue with using a variable inside a $row?  Is there a syntax error (no error messages)?  Perhaps a MySQLi addition that is required?

  10. A silly question, since simply fixing the error would likely take less time, but my curiosity won't stop nagging me.

    I have several php pages that ALL use the INCLUDE file connection.php which has the following scripting

    $conn = mysqli_connect(...etc, etc,etc,);

    Everything works fine EXCEPT for a few pages which were written using $DBCONN   instead of  $conn

    Can I somehow alter the value of $DBCONN so it is  equal to $conn

    And interpreted correctly without having to change the mistaken variable in the pages that use $DBCONN   ?

    I tried a quick $DBCONN = $conn; but there was no effect, so I thought I'd ask.

     

  11. Now that I'm playing with ERROR messages, I see that

    or die(mysqli_error())

    provides the line number that corresponds to the coding issue, but differs from

    or die(mysqli_error($conn))

    which specifically gave me a reason for the unsuccessful effort.

    Is there a simple way to display BOTH pieces of information, or does an IF statement need to be created?

  12. I have many BLANK lines for easier reading in my coding.

    My first ERROR MESSAGE read:

    Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home/..... on line 368

    So, I commented out line 368

    $result = mysqli_query($conn, "SELECT * FROM $table WHERE id = $record_id ");
    //or die(mysqli_error());

    This took me to the following:

    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/.... on line 378

    $row = mysqli_fetch_array( $result, MYSQLI_BOTH );

    which is required to fill fields with data from my table.

    I guess I need to fix the fetch and the mysqli_error for a fully acceptable coding result.

  13. I am updating some old code to the IMPROVED version of PHP and running into a problem in this section after connecting successfully to my database:

    // retrieve the record that was selected
     $record_id = (isset($_POST['record_id'])) ? $_POST['record_id'] : '';
    
    //check for $record_id emptiness
    if(!empty($record_id)){
    
    // Retrieve ALL the data from the "example" table
    $result = mysqli_query($conn, "SELECT * FROM $table WHERE id = $record_id ")
    or die(mysqli_error());
    
    // store the record of the "example" table into $row
    $row = mysqli_fetch_array( $result, MYSQLI_BOTH );
    
    } 

    Not sure what I'm missing or what needs to be re-organized.

    Please advise.

  14. I opened the webpage in both Firefox and Chrome and got the same result. 

    I'm going to conclude that since these are the same browsers that played the video from W3 (both while at their URL and after saving the file locally) that it is not a browser issue.

    How do I proceed regarding the codecs, or is their a simpler / more effective way to make a simple screen recording for use on a webpage?

  15. This is a first time effort to create a video of my local pc workstation screen.

    Attempt #1 utilized an application provided in Windows 10 to create the MP4 file.

    Attempt #2 was to convert a Powerpoint 2010 presentation into an MP4 file

    Both seemed to go well, and produced files then when clicked independently on the desktop, will play their clip.

    However, when called from a local webpage "No video with supported format" is the message displayed where the working video is expected.

    <video width="400" controls>
      <source src="mov_bbb.mp4" type="video/mp4">
      <source src="mov_bbb.ogg" type="video/ogg">
      Your browser does not support HTML5 video.
    </video>
    
    <video width="400" controls>
      <source src="Presentation2.mp4" type="video/mp4">
      <source src="Presentation2.mp4" type="video/ogg">
      Your browser does not support HTML5 video.
    </video>

    I borrowed a video clip from W3 and it seems to work fine, which leads me to believe that either I am creating a damaged file or the file is not truly MP4.

    The file PROPERTIES indicate it is MP4 in all instances.

    Where did I go wrong?

  16. More info.....

    Here is my original code that works well PRIOR to attempting to acquire the LAST INSERT ID:

    $query  = "SELECT * FROM table WHERE email='$email' ";   //checks that email is unique
    $result = mysqli_query($conn, $query);                   //RUNS the above query
    if (mysqli_num_rows($result) == 0) {                     //if no duplicates exist, then INSERT
    
    $sql="INSERT INTO $table..... etc etc
    
    }

    So the question remains, how do I retrieve the LAST INSERT ID without having duplicate entries into my table, and without restructuring my code too drastically (as to affect other portions that use the same CONN).

  17. Fought with code until I eventually put this after my INSERT statement:

    if (mysqli_query($conn, $sql)) {
        $last_id = mysqli_insert_id($conn);
        echo "New record is: " . $last_id;
    } else {
        echo "Error: " . $sql . "<br>" . mysqli_error($conn);
    }

    I finally got the ID value, except all entries into the table are being duplicated from each single form submission.

    It appears that this is because $sql is being called twice.  I even tried to put this into a function (didn't execute at all).

    How do I get to a single table posting?

  18. I don't mean to bother you with silly questions, but I must be using the wrong search terms to find any viable answers to this.

    Hypothetical situation:  I have a table [Customers] with with an auto-increment id, customer_name and email generated from a form.

    Now, I decide to expand my database to include customer-address and telephone number.

    I decide to create a second table named Contactinfo for this purpose (assuming this is a better database practice).

    As Customerinfo is generated, I want it to POST in association with the respective customer (assuming that 'id' is the best field for association).

    I need some examples and best practices to accomplish this.

    Examples, links, or preferred terminology would be great so I can attack this phase.

    Thanks.

  19. Okay, got it.

    Yes, dates are in table.

    I believe I used SQL previously and this will add to it. If I'm not mistaken, I also used a PHP adaptation to test outside of the table (so that I could get comfortable with it and see results more easily).

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