| | |
How to check cells of a column
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
I am trying to crosscheck a column in a table with 30 rows.
Example:
The logic to my knowledge is the select statement is done on table characters and then a fetch array is processed based on that query. If statement checks if there is the same value of 'a' in both the variable and the cell if so, counter is increased by 1. Finally the counter variable is echoed out.
I am stuck at the for loop logic, please help.
Thankyou, Regards X
Example:
php Syntax (Toggle Plain Text)
$value = "a"; $sql = "select * from characters"; $query = mysql_query($sql); $fetch = mysql_fetch_array($query); for ($i = 0; $i < 30; $i++) { if($value == $fetch['letters']) { $counter++; } } echo $counter;
The logic to my knowledge is the select statement is done on table characters and then a fetch array is processed based on that query.
PHP Syntax (Toggle Plain Text)
Im confused now I cant think of the logic on how to check 30 repeated rows each time.
I am stuck at the for loop logic, please help.
Thankyou, Regards X
"You never stop learning." - OmniX
hello try this:
PHP Syntax (Toggle Plain Text)
$sql = "select * from characters where letters like '%a%'"; $query = mysql_query($sql); $count=mysql_num_rows($query); echo $count;
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Shanti my hero!
Nice that works but I what I require is a bit more complex like comparing $variable string vs. $cell content instead of just a.
Thanks, Regards X
Nice that works but I what I require is a bit more complex like comparing $variable string vs. $cell content instead of just a.
Thanks, Regards X
"You never stop learning." - OmniX
see this:
PHP Syntax (Toggle Plain Text)
$variable="a"; $sql = "select * from characters where letters like '%".$variable."%'";
Last edited by Shanti Chepuru; Oct 15th, 2008 at 3:20 am.
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Logic works but I need to tinker with it.
If someone can fix the for loop problem be much appericated else ill try work with shanti's example.
Thanks, Regards X
If someone can fix the for loop problem be much appericated else ill try work with shanti's example.
Thanks, Regards X
"You never stop learning." - OmniX
![]() |
Similar Threads
- check box in datagrid view (VB.NET)
- datagrid coantianing checkbox as column (ASP.NET)
- Collapsible table sorting problem (JavaScript / DHTML / AJAX)
- javascript works in IE but not working in firefox (JavaScript / DHTML / AJAX)
- can anyone make this tree table sort correctly? (JavaScript / DHTML / AJAX)
- Please help! Sudoku in C (C)
- need Help in store Datagrid item in an array (VB.NET)
- Replace repititious code with a loop? (Visual Basic 4 / 5 / 6)
- Help for my project (Java)
- Adding a checkbox column dynamically (C#)
Other Threads in the PHP Forum
- Previous Thread: PHP Multiple Existing DB Entries
- Next Thread: T_VARIABLE error!!!
| Thread Tools | Search this Thread |
apache api array basic beginner binary broken cache cakephp checkbox class cms code computing confirm cron curl customizableitems database date delete display dynamic echo email error external file files filter folder form forms forum function functions gc_maxlifetime google headmethod host howtowriteathesis href htaccess html iframe image include insert ip javascript joomla limit link login mail malfunction memmory memory menu mlm multiple mysql navigation oop parsing paypal pdf php phpmysql problem query question radio random recursion remote script search select server sessions sms snippet source space sql syntax system table thesishelp trouble tutorial update upload url validator variable video web youtube






