Hi Everyone,
I'm trying to convert my MySql data into variables so I can use them on my website. For example, if I want to convert a city or even first or last name into a variable. How would I go about doing that? Thanks everyone!
How to convert MySql data into variables?
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: How to convert MySql data into variables?
Depending on how you retrieve the results (mysql_fetch_object, mysql_fetch_array, mysql_fetch_row) you can use that to access the values.
If you want to create and use (other) variables you can equate the above values like this -
Code: Select all
<?php
//
$obj = mysql_fetch_object($sql);
echo $obj->field1; // $obj->field1 contains data present in 'field1' of your table
// etc.
?>Code: Select all
<?php
$field1 = $obj->field1;
echo $field1;
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering