Jump to content


Photo

field name into a variable


  • Please log in to reply
3 replies to this topic

#1 alarik149

alarik149
  • Members
  • PipPipPip
  • Advanced Member
  • 60 posts

Posted 08 March 2006 - 05:25 PM

hi all you guru PHP&MySQL people.
I want you to help me with something.
So I have a database named championships and in it I have 5 fields with names '1''2''3''4''5'.
I want the variable $a to hold the name of the field '1',how do I do that?pls tell me.
thank you in advance:)
Tired of math homework ? Just visit http://www.solvemymath.com for a free online math solver and calculator.
Videochat bucuresti studio -> http://www.GirlAddicts.com
About the adult video chat business -> www.girlplan.com

#2 alarik149

alarik149
  • Members
  • PipPipPip
  • Advanced Member
  • 60 posts

Posted 08 March 2006 - 05:50 PM

or tell me how do i detect the name of a field that contains a certain text.
for example how do I get the name of the field that holds litter "abcdef".

Tired of math homework ? Just visit http://www.solvemymath.com for a free online math solver and calculator.
Videochat bucuresti studio -> http://www.GirlAddicts.com
About the adult video chat business -> www.girlplan.com

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 08 March 2006 - 05:55 PM

Try this:
<?php
$q = "select * from tablename";
$rs = mysql_query($q) or die('problem with query: ' . $q . '<br />' . mysql_error());
while ($rw = mysql_fetch_assoc($rs))
     foreach ($rw as $key => $value)
          if ($value == 'abcdef') echo 'The field ' . $key . " holds the value<br />\n";
?>

Ken

#4 alarik149

alarik149
  • Members
  • PipPipPip
  • Advanced Member
  • 60 posts

Posted 08 March 2006 - 05:59 PM

it works...yey..thanks a lot man:)
Tired of math homework ? Just visit http://www.solvemymath.com for a free online math solver and calculator.
Videochat bucuresti studio -> http://www.GirlAddicts.com
About the adult video chat business -> www.girlplan.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users