Jump to content

Getting specific values from table with PHP


melefire

Recommended Posts

So, in my latest project I have decided to save all of the visible text a "strings" in a table in my database. The database structure is as follows:

+----+------+-----------------------------+------------+
| id | name | default_value               | cust_value |
+----+------+-----------------------------+------------+
|  1 | str1 | This is a demo string       |            |
|  2 | str2 | This is another demo string |            |
+----+------+-----------------------------+------------+

So I got the contents of the table called 'strings' like this:

$strings = mysql_query("SELECT * FROM `strings`;");

 

I know this selects the whole table with all the data.

 

Then I make an array out of it:

$rawData = mysql_fetch_array($strings);

 

From there I need to be able to pull out individual strings... how would i go about doing this

 

Can anyone help?

thanks

Link to comment
Share on other sites

You can try this just use your info

 

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


//you can use somthing like this to grab all the content


while ($r=mysql_fetch_array($result))

{	

   //the format is $variable = $r["nameofmysqlcolumn"];

   //modify these to match your mysql table columns and add more if needed

  
   $id=$r["id"];

   $name=$r["name"];


      //display the row

echo "".$id.", ".$name."<<br />";

}

 

also here is a good site for getting the basics

 

http://www.tizag.com/phpT/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.