Computer problems,Computer help
*AX SOFT>>>Programming & Design

PHP and MYSQL newbie question!?


Hi im pretty new to this so hopefully should be pretty easy to answer...

Basically I want to store the output from an SQL statement in a variable, but im not quite sure of the syntax that need to be used. My SQL statement is:

SELECT f_name FROM auth_users WHERE username = 'smithy22'

This should return the name David. David is what I want to store in a variable, so how do I go about doing this? I need to do something like this...

$first_name = SELECT f_name from auth_users where username = 'smithy22';

Anyone have any ideas? Thanks

hi dr_bucks, thanks for your answer, but its the PHP code for storing the output in a variable that I need. The MYSQL statement I have produces the output I require.

mysql_connect("localhost", "dbusername", "dbpassword") or die ("Could not connect to database");
mysql_select_db("dbname") or die ("Could not select database");

$result = mysql_query("SELECT f_name FROM auth_users WHERE username = 'smitty22'");
while($row = mysql_fetch_array($result))
{
echo $row[f_name] . "<br/>";
}

why not try

SELECT f_name FROM auth_users WHERE username LIKE 'smithy22'

Since you are a newbie to PHP and MySQL, this search code may be some use to you. It is a full PHP search script that searches through multiple MySQL table and ranks results. Visit.....

http://www.mysqlphpcode.com

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • Is there a way to encrypt an entire partition with existing files still stored on it?

    Truecrypt is a volume encryption method, not a file encryption method, so you have to start with an encrypted volume. However it's well worth the extra work, (saving the files somewhere else ...

  • How do i use megaupload?

    First open the file you want to download and then enter the three letter verification code on the top right hand side of the yellow screen and click submit or something simmilar and you should get ...

  • Centering with CSS ("margin: auto" not working...)?

    Wish I had your images to double check this with, but it centers in Firefox and IE for me: <style type="text/css"> #titlebar { width: 450px; margin: 0 auto; height: 100px; ...

  • Photoshop!!?

    try this: tutorialized.com there are a lot of photoshop techniques here

    ...
  • Voip and Sip with java?

    This is very hard if you do not know programming very well. However, to help you on your way, you will need to look at the java media framework (JMF): ...

  • Is there a free web page,Were I can learn to do graphics?

    To use Adobe Photoshop here a website with tutorials ...

  • Help with PHP web form submit message?

    Try: $numoferrors = count($errors); if ($numoferrors > 0) { echo $errors[0]; exit; } Then you are just printing out the first error in the array.So once they correct that and...

  • How to display a category menu in Drupal's front page?

    Two steps... 1) Set up your categories (make sure the Taxonomy module is enabled). 2) Set up menus that point to your category URLs. You might also consider the Taxonomy Menu add-in module...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster