how to set a variable to a value in a MySQL DB?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

how to set a variable to a value in a MySQL DB?

Post by Mythic Fr0st »

THIS is not like the others lol...


Q1: how do I select a specific one line (E.G select line 32, and set a variable to it)

so $strlvlmon = $row['myrow'] (select certain line in that row)
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

Do you want to fetch the long text and want to display only the certain line from that long text ?
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

umm

Post by Mythic Fr0st »

say I have

baby elf, (baby elf info)
wood elf, (wood elf info)
dark elf, (dark elf info)
blood elf, (blood elf info)

now, if I type the below it will reveal the stuff for baby elf, conditional to the row I want

Code: Select all

$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("monsters", $con);

$result = mysql_query("SELECT * FROM m_l");

$row = mysql_fetch_array($result);
$ml=$row['mlvl'];       //<(mlvl being row)
$strlvlmon=$row['strlvlmon'];
$strdmgmon=$strlvlmon / 4;
$strdmg=rand(0, $strdmg * 1.3);
$strdmg=round($strdmg);
Now, how could I directly skip to say blood elfs stats? without typing the above 3 more times...

(btw mlvl is my main level, and i've set it to auto_increment thing, I read somewhere its used to track a certain section...
hmph
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Stop making new threads for the same problem Mythic Fr0st. That's twice I've had to lock a thread. I won't let it go too much farther.
Locked