Jump to content

Archived

This topic is now archived and is closed to further replies.

allydm

Mysql results and arrays

Recommended Posts

Hi.
I have a table, which contains 'setting' information for my website.
The table has the following columns: setting_id, setting_name and setting_value.
Now there are currently 30 rows stored in this table, however i am having trouble pulling rows out on a 'as needed' basis.

At the moment i have this select query:
    $settings_query = "SELECT * FROM `robin_settings`";
    $settings_result = mysql_query($settings_query);

And from that, i would like to pull individual results, for example...

I have a setting which has a 'setting_id' of "4", a 'setting_name' called "banner_on" and a 'setting_value' of  "1".

How am i able to pull that information from the results i get?

I know i could pull it by putting a WHERE clause on the SQL query, however that would mean having 30 select queries per page and i don't really fancy that!

Thanks for any help! (i'm new at this :) )

Alex.

Share this post


Link to post
Share on other sites
ever thought of a search function??

// Search database
  $select = $_POST['select'];
  $for = $_POST['for'];

// Get all the data from the "Users" table
  $Result = mysql_query("SELECT * FROM individuals WHERE $select LIKE ('%$for%') ORDER  BY Surname              ASC ");

<form name='Search' method='post' action=''>
                    <label>
                    <select name='select'>
                        <option value='Surname'>Surname</option>
                        <option value='Names'>Full Names</option>
                        <option value='idno'>ID Number</option>
                        <option value='Email'>Email</option>
<option value='Company'>Company</option>
                    </select>
                    </label>
                      <td width='50' align='left' valign='top'></td>
                      <td width='34' align='left' valign='top'><strong>For : </strong></td>
                      <td width='144' align='left' valign='top'>
                    <label>
                      <input type='text' name='for' value='$for'>
                    </label>
                      </td>
                      <td width='71' align='left' valign='top'>
                    <label>
                      <input type='submit' name='Submit' value='Search'></td>
  <td valign='top'><input type='submit' name='All' value='Show All'></td>
                    </label>
                    </form>

It works like a bomb!

Share this post


Link to post
Share on other sites

×

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.