Jump to content

MartynA

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

MartynA's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [quote author=kenrbnsn link=topic=101836.msg403418#msg403418 date=1153860104] Try changing your mysql_fetch to mysql_fetch_assoc(), then you would reference the field with $row2['user'] and the code to print: [code]<?php print $row2['user'] . $variable; ?>[/code] The next question is ... why do you want to do this? Maybe if you explain what you want to do, we can come up with an easier way of doing it. Ken [/quote] Thanks Ken, that did it. For any future reference, I was wanting to foreach through an array containing values such as 5,7,6 and then echo out the equivalent, e.g. $row2->user$valueinarray. That way I could define what information I wanted printing just by passing an array to the function. Thanks, and sorry for not explaining myself so well.
  2. Thanks; close but no cigar. Your code gave me an error so I looked up the eval syntax and came up with [code]eval("print \"\$row2->user$variable\";");[/code] However, that doesn't output anything. At all. What I am doing wrong?
  3. Hi, I hope one of you guys can help, I have a slight problem involving arrays and variables: I have an object array, $row2 populated with data pulled from mysql. Hence $row2->name grabs the name part of the query. Now, i want to do a foreach loop to display some of these, specifically user2, user7 etc. Long story short, how do I concatenate $row2->user with the array key - or any thing else for that matter: [code]$variable = "7"; print "$row2->user" . "$variable"; [/code] This doesn't work, and only outputs 7, not the contents of $row2->user7. I suspect I'm missing something obvious here, anyone wanna fill me in? Thanks, Mart
×
×
  • 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.