Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7942779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:04:23+00:00 2026-06-04T00:04:23+00:00

I have a form which allows my user to edit the information as required.

  • 0

I have a form which allows my user to edit the information as required. As part of this form, the user can insert up to 5 types of proof. All proof is stored in a seperate table:

Table: Proof

proofid - primary key
banid - foreign key -> links to banlist table which stores all other information
proof - the link to which contains the proof
type - the type of proof (image, demo, league, ...)
number - the index number of the proof (0 up to 4)

I also have the following code to update or insert the item of proof. It loops through each field, and checks if the current selected item in the array is not empty. If true, it checks to see if $i is within the array which stores all the numbers for the selected ban id.

The array looks like this for banid 237: Array ( [0] => [1] => 1 )

This in effect says that the first proof field is empty, but the second is not and that a record exists in the table.

for($i = 0; $i < 5; $i++)
{
    $proof = $checkprooflist[$i];
    $prooftype = $checkprooftypelist[$i];

    if (!empty($proof))
    {                       
        if(!in_array($i, $proofnumberlist))
        {
            $query2 = "INSERT INTO proof (banid, proof, type, number) VALUE ($id, '$proof', '$prooftype', $i)";
            $result2 = mysql_query($query2);
        }
        else
        {
            $query2 = "UPDATE proof SET proof = '$proof', type = '$prooftype' WHERE number = $i AND banid = $id";
            $result2 = mysql_query($query2);
        }
    }           
}

The problem I have however is that with the above array, the line if(!in_array($i, $proofnumberlist)) is returning false and thus not entering the if statement when $i = 0.

It works for all other values (where $i = 1, …) and so forth but not when $i = 0.

Thank you for reading and I appreciate any help you may be able to give me.

Jon.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:04:25+00:00Added an answer on June 4, 2026 at 12:04 am

    On the other hand, you could sidestep the entire in_array check by using INSERT ... ON DUPLICATE KEY UPDATE.

    This would make your code a bit clearer. See http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a template which allows the user to edit their user information. <form
I have a HTML form which allows a user to add rows ad hoc
I have this form which allows the input of any product quantity from 1-10:
I've got a form that allows the user to edit an employees information: name,
i have a form which allows the user to upload some files to a
I have a form which encapsulates all the functionality, but works with a concrete
I have a form which users can add controls to and when they right
I have a form which posts date information month, day, yeah, hour, minute, am/pm.
I have code in the following form in which the user may specify a
I have a form which allows to view data in a page or download

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.