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 6118335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:25:28+00:00 2026-05-23T15:25:28+00:00

i’m currently working on a script to randomize different values of input. Here is

  • 0

i’m currently working on a script to randomize different values of input. Here is the main part of the php script:

$alive='';
if(isset($_GET['alive'])) {
$alive=$_GET['alive'];
}
$injured='';
if(isset($_GET['injured'])) {
$injured=$_GET['injured'];
}
$deceased='';
if(isset($_GET['deceased'])) {
$deceased=$_GET['deceased'];
}
$unkstat='';
if(isset($_GET['unkstat'])) {
$unkstat=$_GET['unkstat'];
}
$found='';
if(isset($_GET['found'])) {
$found=$_GET['found'];
}
$missing='';
if(isset($_GET['missing'])) {
$missing=$_GET['missing'];
}
$youth='';
if(isset($_GET['youth'])) {
$youth=$_GET['youth'];
}
$adult='';
if(isset($_GET['adult'])) {
$adult=$_GET['adult'];
}
$unkage='';
if(isset($_GET['unkage'])) {
$unkage=$_GET['unkage'];
}
$incidentid='';
if(isset($_GET['incidentid'])) {
$incidentid=$_GET['incidentid'];
}
$limit='';
if(isset($_GET['limit'])) {
$limit=$_GET['limit'];
}

mysql_connect ("$host", "$username", "$password") or die ("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="INSERT INTO $tbl_name (given_name, family_name, gender, status, age, incidentid)
select First10.$gender, Last10.family_name,
(SELECT $gender from gender) AS Gender,
(SELECT * FROM status WHERE status IN ($alive $injured $deceased $unkstat $found $missing)) AS Status,
(SELECT * FROM age WHERE age IN ($youth $adult $unkage)) AS Age,
(SELECT $incidentid from incidentid) AS Incident_ID
from ( select fn.$gender, @fns := @fns + 1 as Sequence
from ( select $gender from fnames where $gender IS NOT NULL order by rand() limit 100) fn,
(select @fns := 0 ) vars ) First10
JOIN
( select ln.family_name, @lns := @lns + 1 as Sequence
from ( select family_name from lastnames order by rand() limit 100 ) ln,
(select @lns := 0 ) vars ) Last10
ON First10.Sequence = Last10.Sequence";

And the html is here:

<p>
Status: <BR>
<INPUT TYPE=CHECKBOX name="alive" value="'alive'">Alive and Well<BR>
<INPUT TYPE=CHECKBOX name="injured" value="'injured'">Injured<BR>
<INPUT TYPE=CHECKBOX name="deceased" value="'deceased'">Deceased<BR>
<INPUT TYPE=CHECKBOX name="unkstat" value="'unknown'">Unknown<BR>
<INPUT TYPE=CHECKBOX name="found" value="'found'">Found<BR>
<INPUT TYPE=CHECKBOX name="missing" value="'missing'">Missing<BR>
</p>

<p>
Age: <BR>
<INPUT TYPE=CHECKBOX name="youth" value="'youth'">Youth (0-17)<BR>
<INPUT TYPE=CHECKBOX name="adult" value="'adult'">Adult (18+)<BR>
<INPUT TYPE=CHECKBOX name="unkage" value="'unknown'">Unknown<BR>
</p

What I am trying to do is pull the values from the checkboxes and insert the checked values into a mysql query. The query will then search for these values in premade tables and insert them into a separate table. My problem here is that whenever I pull in the variables, I receive a syntax error that usually results in something like this:

‘SELECT * FROM status WHERE status IN (‘alive’ ‘injured’ ‘deceased’ )
AS Status’

It appears that the values within the parenthesis require commas to separate them, but I cannot think of, nor find a way to efficiently do this. Please advise. You guys are great 🙂

  • 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-05-23T15:25:29+00:00Added an answer on May 23, 2026 at 3:25 pm

    Create an array. Push each set value to the array using array_push. Then use implode(",",$array) to create comma separated value variable. Use that within your IN statement

    Example in conjunction with PeeHaa’s response.

    $vars = array('alive', 'injured', 'deceased', 'unkstat', 'found', 'etc', ); 
    $result = array(); 
    foreach($vars as $var) { 
       if (isset($_GET[$var])) {
         array_push($_GET[$var], $result);
       }
    }
    $result = implode(",",$result);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I would like to count the length of a string with PHP. The string
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

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.