Jump to content


Photo

Mysql results and arrays


  • Please log in to reply
1 reply to this topic

#1 allydm

allydm
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 10 October 2006 - 07:13 PM

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.

#2 GremlinP1R

GremlinP1R
  • Members
  • PipPipPip
  • Advanced Member
  • 62 posts
  • LocationSouth Africa

Posted 10 October 2006 - 07:43 PM

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!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users