Jump to content

2 problems with different arrays...


glennn.php

Recommended Posts

i have a large form - someone in here kindly showed me how to concantenate this array into a query:

 

$twofour = $_POST['twofour'];
if ($twofour != '') {
$twofour_sql = implode(',',$twofour);
} else {
if ($twofour == '') {
$twofour_sql = '';
}
}
if ($twofour_sql != '') {
$where[] = "prg_2_year IN ($twofour_sql)";
} 

 

this works with a set of integers, but i have arrays that are abbreviations, AL, AK, AR etc, with which i'm getting errors, and i'm assuming i have to get them in quotes, but i don't know how (if that's the problem). believe me, i've tried, and i have no idea how to find something like this in documentation at mysql.com or php.net or anywhere...

 

//*******************//

 

i have an array where i need to use BETWEEN like this: ...from table WHERE enrollment BETWEEN 1 and 200 OR BETWEEN 201 and 500...

 

i made the values of the checkboxes "1 and 200" and "201 and 500", but i still can't configure the Form/function correctly.

 


$enrollment = $_POST['enrollment'];
if ($enrollment != '') {
$enrollment = implode(',',$enrollment);
} else {
if ($enrollment == '') {
$enrollment = "";
}
}
if ($enrollment != '') {
$where[] = "enrollment BETWEEN $enrollment";
} 

 

i really appreciate any help that someone can offer. when i see code, i can see how something's done much more easily than reading or hearing "how" to do it...

 

Thanks again,

GN

Link to comment
https://forums.phpfreaks.com/topic/123759-2-problems-with-different-arrays/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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