Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Comma Separated List In MySQL Field


say I have a list of categories in a field, and a page that is supposed to pull from the db based on a category. Is there any way I can do a query where it searches the contents of that field for the category in question?

like SELECT FROM table WHERE category = $category  but have it search the category field (the comma separated list for each entry) for the $category var




View Complete Forum Thread with Replies

Related Forum Messages:
Re Comma Separated List - Another Question
I can do the match perfectly but what i also need to do is create a third
list of comma separated values that are in both

eg:

List 1 => 1,2,3,4,5,6,7,8,11
List 2 => 1,3,4,5,6,7,10,23

Therefore

List 3 => 1,3,4,5,6,7

How do I populate this third list - I'm really stuck ....

View Replies !
Comma Separated Values
What i've done is when the user enters the client list separated by commas..... this works, but I need to know how to warn the user when they have enter the client list with no commas.

Is there some sort of function which does this or is it a regular expression thing??

View Replies !
Exploding Comma Separated In Array
I'm looking to explode the comma separated values in an array like this:

Array ( => 10811 [1] => 7527,7556 )

and then add the exploded value as a new key in the array...like this:

Array ( => 10811 [1] => 7527 [2] => 7556 )

View Replies !
Comma Separated Text Files
A client has requested that I make a php app which takes an uploaded image, reads the values and enters them into a database. I've made the upload script which works fine, and the script which enters the values into the database, the only thing left now is how do I make PHP read the file and extract the values? The file is a text file, each field comma separated.

View Replies !
Count Comma Separated Values In String
PHP form that checks $name doesn't already exist and then inserts them into mySQL database. All works except for the $counted variable. $list is a string that looks something like this: 123,2536,2346,332,546.

So in this instance $counted should have a value of 5 because there are 5 values in the string. But it gets inserted as 0. Cannot see what I am doing wrong. Code:

View Replies !
Regular Expression, Validate A List Of Numbers Separated
I need a regular expression that validate a list of numbers separated
by "-" , numbers can not be greater than 999
Valid examples
0
12-455-01
1-9
125-32-155-45-45
Invalid examples
-1
45-
1-45665456-4
12-45-
-
.......

View Replies !
Pull Data From Mysql From A Varchar Field With Comma Seperated Data
I'm trying to pull data from mysql from a varchar field with comma seperated data, like: test, test, test, and so on. when I try to display the data i just get "array" in the input field. what i'm wondering is how can I show the data correctly? I'm a little lost here.

View Replies !
Mysql Field List
We would like to be able to  get the column list of a mysql Table from PHP code.  I know from the mysql prompt we can get it, but we want to  generate PHP  code
that  will retun an array  of columns  If   there is a column descriptor containing
name, size, etc, that would be great. Something that I could loop thropugh an array in
PHP4 and   get  the names of all the columns in the table as well as perhaps
other column  parameters as well. I believe that can be done in CGI, but want to use
PHP4.

View Replies !
Print Out A List Of All Mysql Field Names
I'm trying to make a drop down menu which has got a list of all field names that are in a database so you can do a search in each field seperatly but i can't find out how to do it.. can it be done with mysql_field_name and if so then anyone knows how ??

View Replies !
Breaking Up A Comma Seperated List
i have a list seperated by commas: 1. 3. 5. 7. 9 actually is a varible

$members ="1, 3, 5, 7, 9"; what would be the best way to break that up to insert the values into a table in a loop.

View Replies !
Comma Seperated List Comparison
is it possible to compare acomma separated list aginst another

eg comma list 1 => 1,2,3,4,5
comma list 2 => 3,5
can you check that 3 is in both, and 5 is in both, therfore they match?

the comparison is to check that if product a who supplies products 1,2,3,4,5
can be used instead of product b who supplies 3,5 as product a already
supplies them

View Replies !
How To Remove Last Comma From A Multiple List?
I have a multiple select list in my site where the values are inserted in a database table, in a column named available_country. I enter these values in the db separated with comma. I don't know however how to remove the last comma so it will be something like this:

USA, Europe, Asia

and not:

USA, Europe, Asia,

Here's what I tried but it didn't worked: ...

View Replies !
Meaning Of Comma After Bracket Eg. List(, $value)
i cant find what this means when you have a comma after a bracket as in for example

php list(, $value)

anyone could explain why that comma is there or at least what its called so i can read about it?

View Replies !
Number Format - Put The Comma In The Field.
Currently, if the user enters a list_price value of 25,000, my program is changing it to 25; if I enter 25000 (w/o the comma), it's displaying OK, but I'd like to be able to put the comma in the field.

What do I need to change/add to accomplish this? Code:

View Replies !
Preg_split - Field Is Seperated By Comma
I have a text file which each field is seperated by comma. And each field can contain either numeric character or non-numeric character(which is
surrounded by a pair of double quotes).

But my problem is: if I seperate the fields using comma, then the address field will be seperated into 2 array elements array, since my address field itself contains comma. Code:

View Replies !
Array Form A Comma Delineated List
What's the best way to create an array from a comma delineated list?

I have a string assigned to a variable that looks like this: 1,2,3,4

And I would like to create an array so that $arr[0] = 1 and $arr[1] = 2 etc.

It seems so simple but I just can't crack it.

View Replies !
Seperating Comma Seperated Field Entries
i want to seperate my comma seperated field and replace the comma with a line break when displaying so that url1 , url2 , url3 and so on becomes:

url1
url2
url3
and so on.

I know what to do when i know how many urls, but this number is indefinite.

View Replies !
Converting Comma Delimited Field Into Array
I have an array that goes into a MySQL database (via PHP). The only way I could find to insert them into the database was using implode. It goes into the database just great, comma separated (although I would like each to go into it's own field, but it's okay for now).

The problem comes when I try to display it. Since it's comma delimited it display only the first item in the array. But there are multiple rows that should be displayed.

I'm not sure how to explode it so that it will display them all. I've tried a loop but that just looped the first item in the field (the first part of the array). Code:

View Replies !
Easy Comma-delimited List To Dropdown Box Converter
I was working on a simple converter when I realized that by not setting the id param of the option tag, it wasn't going to send the value of the dropdown box to my php script. I had this to start with: Code:

View Replies !
Regular Expression :: Find Word Matches To Words In A Comma-delimited List
What's the *right* way to find word matches to words in a comma-delimited list. For example, if I have the following comma-delimited list of categories in a mysql db field:

gameboy, nintendo, playstation

and I do a search, I know I can use regexp to do something like:

select * from categories where regexp 'gameboy,'

Notice that I have the comma in there to match the whole word and the comma without matching part of a word (to prevent unwanted matches such as "play" to "playstation" or "game" to "gameboy"). The problem I'm running into is words that match that match the end of each word next to the comma (in this example, "boy" and "station"). What's the right way to match a word *exactly* using regexp *without* also matching *part* of a word.

View Replies !
Reading Excel To MySql Or Comma Delimited ...
right direction on how to deal with an xls
flie.

but the only other file I have to work
with is pdf.

I'm not sure, is xls the better of two evils?


View Replies !
Field List Is Ambiguous
The query gives me this error: Column 'id' in field list is ambiguous, but I don't see any ambiguity there.

select count(0) from employerInfo i
left outer join employerJobfairs e on i.id=e.id
left outer join jobfairEvents v on e.jobFair=v.id
where i.id!='' && cityOfInterest='FL'
&& i.id in (select id from employerJobfairs where repName!='')
&& i.id in ( select id from employerJobfairs e,jobfairEvents j where j.jobfairDate>=now() && e.jobFair=j.id )


View Replies !
Displaying Table Field List
I got a function that displays a list of the fields in a certain mysql table.  I got it off of this site.  The problem is that it only displays the word Array and I'm not sure why.  This is the code for the function: Code:

View Replies !
Multiple List Values To One Field
I'm trying to figure out if there is a way to input multiple selections from a list in a form field into one field in MySQL. Right now my list is only inputing the first value selected and not the others.

View Replies !
Putting A Dir In A Form List Field
Imagine my excitement when I got the following code to display a directory listing of an image upload area. PHP Code:

<?php
$current_dir = 'images/upload/'
$dir = opendir($current_dir);

echo "Upload is $current_dir<br />";
while ($file = readdir($dir))
{
echo "$file<br />";
}
closedir($dir);

?>

View Replies !
Unknown Column 'icaodesc' In 'field List'
I'm getting the following error message...

Unknown column 'icaodesc' in 'field list'

when I try to update a table from a PHP form.

What 'field list' is it referring to? My PHP script or the MySQL
table???

Here is the PHP script I'm using...

<?php

//set up table and database names
$db_name ="xxx";
$table_name ="yyy";

//connect to server and select database
$connection = @mysql_connect("localhost","user_name","password") or
die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());

//build and issue query
$sql ="UPDATE $table_name SET
icaodesc ='$_POST[task_icaodesc]',
icaosource ='$_POST[task_icaosource]',
icaonote ='$_POST[task_exp_outcome]',
usposition ='$_POST[task_usposition]',
expoutcome ='$_POST[task_exp_outcome]',
usposition ='$_POST[task_usposition]',
usaction ='$_POST[task_usaction]'
WHERE task_id ='$_POST[id]'";

$result = @mysql_query($sql,$connection) or die(mysql_error());
?>

icaodesc was the NAME in the updatable form. task_icaodesc is a
"good" field in the table yyy

View Replies !
SQL/DB Error -- [Unknown Column 'M' In 'field List']
I have a simple form element that drives me nuts. Here's the code: PHP Code:

<input type='radio' name='gender' value='M'";
    if ($usr->act_gender == 'M') { echo " checked"; } echo "> Male
&nbsp;&nbsp;&nbsp;&nbsp;
<input type='radio' name='gender' value='F'";
    if ($usr->act_gender == 'F') { echo " checked"; } echo "> Female

When the form submitted it should PHP Code:

("UPDATE act_details
SET ... gender=".$_POST['gender'].", ...
WHERE ID = '".$user."' LIMIT 1")

But I keep getting the following error: Quote:

SQL/DB Error -- [Unknown column 'M' in 'field list']

Even Thought I have such a field in my db table.

View Replies !
How Does Myadmin List Field Names To Edit?
I'm trying to setup an edit page so that the user can edit any data he entered earlier.
Say he entered all his stuff in and found a mistake and he wanted to go in and make a change. Simple UPDATE command. Code:

View Replies !
Invalid Query: Unknown Column In 'field List'
I'm getting this error when I execute my form and it brings up the corresponding .php page.

Invalid query: Unknown column 'DCS' in 'field list' Whole query: SELECT DCS#, CLIREF, GUAR, PAT, ADDR1, ADDR2, CITY, ST, ZIP, SS#, DOB, PHONE, DBAL, TBAL, PAID FROM crossroads10 WHERE CLIREF='ZQ02037/8558'

Here is my code:

View Replies !
Error: Unknown Column 'OOM210' In 'field List'
Can someone tellme why I get the following error?

Error: Unknown column 'OOM210' in 'field list'

$flightnumber is equal to OOM210...

(INSERT INTO and VALUES are on the same line, but here it is split so it is easier to compare.)

$sql = "INSERT INTO flights (flight_num, dept, dest, depticao, desticao, depttime, desttime, stops, duration, freq)
VALUES ($flightnumber,$departure,$destination,$departurecity,$destinationcity,$departuretime,$arrivaltime,$stop,$duration,$freq)";
  if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }

View Replies !
Book ERROR: Unknown Column 'Fredrik' In 'field List'
In confused with this problem, My code looks like this:

$sql="INSERT INTO calendar(year, month, day, name)
VALUES('$year','$month',".$_GET['day'].",".$_SESSION['name'].");

the table structure of "calendar" is

year TINYINT(4) notnull
month TINYINT(4) notnull
day TINYINT(4) notnull
name VARCHAR(30) notnull

View Replies !
Select Both Field Name And Field Value- Mysql ?
What function to use to select both field name and field value from a mysql table ?

View Replies !
Values Separated By "
How do I read a value written in the first tab of the last line of a text file where values are separated by " "?

View Replies !
Zip Code Separated By Hyphens
I am storing 5 digit zip codes selected by clients like this, in a table. PHP Code:

56510-56511-56514-56519-56525-56529-56536-56541-56546-56547-56548-56549-56550-56552-56553-56554-56560-56561-56562-56563-56574-56579-56580-56581,

In my query I am first selecting this data and replacing the hyphen with a comma, like this. PHP Code:

$selectedzip[] = $row["selected_zip"];
$selectedzip1 = str_replace("-", "","", $selectedzip);  
$selectedzipstr = implode("','", $selectedzip1).

View Replies !
Separated Numerical Values
My source file contains numerical information shaped like this:

32,567,90
32,689,78
et cetera

If I use (longint)$numstr I get 32 as value (logically). How can I convince php to ignore the, in these strings Probably in the manual, but I could not find an entry for this.

View Replies !
Count The Value Separated Through Explode Function
Currently i'm using an explode function to separate the value from a variable...

For Example,
$var1='username,user_type,filetoload'
$var2=explode(",",$var1);

So from here i can extract these 3 values separately...

$extract1=$var2[0];
$extract2=$var2[1];
$extract3=$var2[2];

My question is, how do I want to count that this explode function has extracted 3 values? maybe from the variable $var1='username,user_type,filetoload'
is it possible that i know $var1 contains 3 values ..?

View Replies !
Comparing Arrays - Separated By Commas
I have a MySQL database which has a load of musicians on it. Each musician has a field that stores their influences, which are separated by commas, e.g: The Beatles, The Beach Boys, Kiss etc etc.

Now, what I would like to do is start with the influences of one musician, and then compare it to all the others to find the closest matches - i.e find the musicians that have (say) more than three influences i common. This would then allow you to see which musicians had the most influences in common with the primary one, the one you started with.

Here's what I have in mind, it seems a little laborious - load the influences of the primary musician into an array using the explode command. Then step through each of the other musicians in a loop, each time putting their influences in to an array and checking to see how many matches there are between the two arrays. Whenever there is at least one match, the name of the musician and the number of matches would be put into a third array. This array would then be sorted at the end, so that the musicians with the most matches would be at the top, and the script could then display them.

This would probably work, but if looking at several hundred or several thousand musicians, it would surely be quite slow - is there a better way? I don't particularly want to use a separate, normalised table at this point - I know it would be the quickest way but it would involve a lot of restructuring for me. I know that PHP has several clever inbuilt routines that might do this job for me, so if anyone can suggest anything I'd appreciate it.

View Replies !
Inputting Integers Separated By Comma's
I have a script which is suppose to UPDATE a user in the database depending on which button they pressed on the previous page. But it doesn't seem to be running the UPDATE query at all. Code:

View Replies !
Extracting Substrings Separated By New Line Character?
i have a variable with a string let's say 100 lines, one url per line i can't think out a easy way to get each of these urls separetely in order to insert them into a DB

infact they are separated by a new line character (or in some cases space) so i just need a way to read the sub-strings between the new lines....


View Replies !
If/then Within MySQL Results List
I want to list job opportunities for a facility. If there are jobs in the database, I can list them without a problem. But if there are no jobs, I'd like to echo a line something like: "No jobs right now, come back later." But I can't get that line to echo. PHP Code:

View Replies !
2 Drop Down List Using MYSQL
I have a model table with the following fields: MODEL_ID, MAKE_ID, NAME.
And a make table with the following fields:
MAKE_ID, NAME.

The first drop down list (make) to select a make of a car i.e. Chevrolet, Ford. When a make is selected, then all the model for that paticular make appear in the second drop down list.

View Replies !
PHP And MYSQL Drop Down List
I need a script to create a drop down list which has vehicle makes. The vehicle make list should feed a vehicle model list so when I select a make all the models for the make appear in the model list. I have a make table which has MAKE_ID, make NAME and a model table which has MODEL_ID, MAKE_ID and model NAME.

I tried using a script using javascript array but wherever I have a query that pulls the NAME from the database there's always a carriage return after the NAME which messes up the javascript array. I'd rather do it all with PHP if possible. If not please give me one that works and I don't have to spend hours troubleshooting.

View Replies !
Mailing List Using MySQL / PHP
I have written a database which uses PHP to run through each ID in the
database and then generate a persons name and address to include into the
rest of the PHP to send an email out.

But as people have deleted or updated their details on this mailing list, I
now have "holes" in database. Ordinarily not a problem, but the code I've
written starts at ID 1 and after sending an email increments to the next
ID. But when it encounters a now vacant ID, it sends an error email to me
associated with that now blank ID row of data.

How can I change my code that will increment through all the results in
turn, but not give me these error emails when people have amended the
database?

View Replies !
How To List Information From A Mysql Row
am i going about listing data from a mysql row the right way this is what i have so far:

<?php 
include("connect.php");
$tbl_name = "userdata";
$res = mysql_query("select userid from $tbl_name"); 
while($row = mysql_fetch_array($res, MYSQL_ASSOC))
{
    echo "Name :{$row['userid']} <br>" .

?>

View Replies !
List Into MySQL Automatically?
I want to insert the names of these links into my MySQL database, and assign them an auto-incrementing id number. The auto-increment isn't a problem, I want to know if there is a way to insert the names of these school names, without having to type them in individually which would be a very painstaking process.

View Replies !
Php And Mysql Show Only From List
i am calling all data from a database and listing it in a table. The main trouble is that some sections will have a large amount of data in them with different categories. for example, i have a db of mobile phone manufacturers and models.

as you can imagine there are a lot of them. so far i have the data paged with 30 results a page and it is all listed in alphabetical order by manufacturer so it is relatively easy to find data if you keep clicking through the lists.

what i would like to do is have a set of links (which i have done using manufacturer as the title). how do i use those links for the following:

if i click on Nokia for instance, how do i get ALL Nokia only phones listed and not show any other data?

View Replies !
Mysql List Menu
how can I modify this code to list queries in alphabetical order and eliminate duplicate names.

<?php
mysql_connect("localhost", "xxx_xx", "xxxx") or die(mysql_error());
mysql_select_db("xxxx_xx") or die(mysql_error());
$query="SELECT Bloom_Name FROM ihs";
$result = mysql_query($query);

echo '<select name="ihs">'
while($nt=mysql_fetch_array($result)){ //Array or records stored in $nt
echo '<option value="' . $nt['id'] . '">' . $nt['Bloom_Name'] . '</option>'
/* Option values are added by looping through the array */
}
echo '</select>' // Closing of list box
?>

View Replies !
Mysql Dropdown List
Im trying to automatically fill a dropdown list with data from MYSQL table.

Sizes Table
--------

ProductId | size1 | size2 | size3 | size4 | size4 | size6 |

* the 'size' rows hold a numeric value for the quantity I have of each

I was hoping to only list the sizes that have a greater number than 0.
I have used an auto fill select code on another project but I'm just not sure how to fill in the blanks. Code:

View Replies !
PHP, MySQL And BIT Field
my MySQL table contains bit field

Registered BIT(1) NOT NULL DEFAULT 0

I read records using

$result = mysql_query('SELECT * FROM MyUsers');
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$registered = $row['Registered'];

Command "echo $registered;" shows nothing or rectangles depending on the
value, it's ok. But I do not know how to use it in IF statements or so.
Whatever I try does not work. How can I work with such values in PHP?

View Replies !
Mysql Field
I was wondering if there is a way to organize fields with the same value like so:

database-
row 1:
field 1(name): Yamaha. (same name as below)
field 2(item): Speakers

row 2:
field 1(name): Yamaha. (same name as above)
field 2(item): Keyboards

Output:
Yamaha: Speakers, Keyboards

View Replies !
Select List/Menu Using PHP And MYSQL
Here is my code:

<select name="country" class="sidelinks">
<?php
do
{
?>
<option value="<?php echo $row_AllCountries['country_ID']." ";?>"<?php if ($row_AllCountries['country_ID'] = $acountry) { echo "selected"; }?> >
<?php echo $row_AllCountries['countryname'];?></option>
<?php
}
while ($row_AllCountries = mysql_fetch_assoc($AllCountries));
?>
</select>

A few words to describe:
-$row_AllCountries['country_ID'](get from MySQL) is a unique country ID number
-$row_AllCountries['countryname'](get from MySQL) is the name of the country
-$acountry is the country ID number that i want to be selected when the form loads

I have all the values and country names named OK...the only problem is that when the form loads it selects the last country.

View Replies !
Auto-incremented Mysql List?
how when you have an auto-incremented mysql list? And you know how when you delete an entry, the entry's auto-increment value just gets dropped and skipped? What I need to know is if there is a way to sort of re-number the list, preferably using a Query, such as an ALTER command or something. Code:

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved