I gang

loop through mysql columns

We need a col_loop() function in php that loops through all the columns of a given mysql table and identifies specific character patterns.

It will take 3 arguments:

p_table_name

p_record_identifier

p_find_string

For example, suppose we have the widgets table as follows:

id / varchar1 / varchar2

1 / lsdkfabclksdf / asldfkj

2 / fldskflds / dkfabc sdf

The [url removed, login to view] page will call the function as follows:

$myresult = col_loop("widgets","id","abc");

The following would be returned when one runs [url removed, login to view] in the browser (preferably via echo()):

Row: id=1 Column(s): varchar1

Row: id=2 Column(s): varchar2

If we add new columns to the table the script must pick them up automatically the next time it is run.

The function must work with db config files in the following format:

[url removed, login to view]

<?php

$hostname = "localhost";

$dbname = "mydbname";

$username = "myusername";

$password = "mypassword";

?>

The function must include the config file early on in a manner that is well commented so that we can change config files when working with other dbs.

I'm not sure how this should be done in php but it should probably be similar to the jdbc code below:

try

{

Statement s = [url removed, login to view] ( );

[url removed, login to view] ("SELECT * FROM profile");

ResultSet rs = [url removed, login to view] ( );

ResultSetMetaData md = [url removed, login to view] ( ); // get result set metadata

int ncols = [url removed, login to view] ( ); // get column count from metadata

int count = 0;

while ([url removed, login to view] ( )) // loop through rows of result set

{

for (int i = 0; i < ncols; i++) // loop through columns

{

String val = [url removed, login to view] (i+1);

We are still on version 4 of php.

Færdigheder: PHP

Se mere: php mysql loop columns, mysql loop columns, php loop columns, mysql loop column, loop columns mysql, mysql loop, php loop column, php loop mysql columns, loop mysql, loop column mysql, php mysql loop column, php loop mysql, loop column php, using php loop table columns, mysql column loop, mysql loop rows, mysql php loop columns, php loop table columns, loop mysql php, php loop mysql fields, php loop, mysql loop row, mysql loop table, php loop mysql table, loop mysql column

Om arbejdsgiveren:
( 6 bedømmelser ) Antelope, United States

Projekt-ID: #264038

Tildelt til:

dboyzhang

Hi,I can start immediately and complete it in two hours. Regards Bo Zhang

$30 USD in 0 dage
(215 bedømmelser)
6.8

7 freelancere byder i gennemsnit $46 for dette job

zeke

Easy project! Will be finished in several hours after you accept my bid. Let's start! Best Regards, Zeke.

$50 USD in 0 dage
(141 bedømmelser)
6.7
imszone

Hi, please see PM.

$75 USD på 1 dag
(49 bedømmelser)
6.5
neanton

I can do this

$30 USD in 0 dage
(84 bedømmelser)
5.9
exoexo

Very easy job. One hour may be. Lets talk in PMB.

$30 USD in 0 dage
(65 bedømmelser)
5.9
alfredofonseca

i can make your project.. i have experience in php.. html.. css. mysql.. oracle.. design.. javascript... i can start now.. the script is easy... make the query... and get results.. in array... give me oportunity.. Mere

$40 USD in 2 dage
(1 bedømmelse)
2.0
esolzhelp

Clear with requirements, escrow needed.

$70 USD in 2 dage
(0 bedømmelser)
0.0