News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

php/sql question

Started by Dempeduck, December 22, 2003, 08:06:43 PM

Previous topic - Next topic

Dempeduck

I'm redoing my website so all of the content is contained in a mySQL database rather then just written in.  I'm doing this because I want to be able to search through the content, sort it, etc. etc.

Right now I'm doing my "Gear Page" (it's a band site).  So far the search form has two pull down menus ( <select>).  Each has all the option. then a "doesn't matter" option.  However when I go to put my rows in, I realize I don't know how to do this.  I either have to have the rows have two values (the option it belongs to and then the doesn't matter option) (which I'm not sure is possible and if it is I don't know how to do it), or do something fancy.

Any suggestions?
"You thought the leaden winter, would bring you down forever,
But you rode upon a steam to the surface of the Sun"
--Tales of Brave Ulysses, Cream

Aquilo

if you mean have more then one thing for a row but only what you want?
enum('love it', 'dont like it', 'dont matter')

I don't know if an enum() lets you put full words but you could still have enum('e', 'b', 'd') and then translate them to there full words for output.

Dempeduck

#2
I mean have more then one thing for a value in a--bleh!! not good with vocabulary.  Example:

name   pet   residence
bobhorsehouse
joehorse, cathouse, shack

Theres my database (I couldn't get the smfcode(or whatever it's called) to work so I jsut put code thigns around it).  I want Joe to show up when I request all rows with house or shack in column "residence".  As is joe's row would only show up if I requested "house, shack".

hope that clears things up a little.
"You thought the leaden winter, would bring you down forever,
But you rode upon a steam to the surface of the Sun"
--Tales of Brave Ulysses, Cream

Aquilo

oh you want this in a post? I don't know about SMF ubbc but it can be done in YaBB SE but why?

is this something for viewprofile? if so I'll post some code that will help.

Dempeduck

no, no-- I'm doing it for a web page (www.krants.net/austin/Music/geard.htm (form), www.krants.net/austin/Music/gear.php (result(in much progress))

I was jsut trying to clarify what i was saying by using a table, but I couldn't get the tags to work so i put it in a code tag so you could at least see what I was trying to do.
"You thought the leaden winter, would bring you down forever,
But you rode upon a steam to the surface of the Sun"
--Tales of Brave Ulysses, Cream

Aquilo

well you can use a while loop to go through the querys or if it's limit one just one person list them
then you can do something like

list($name, $pet, $residence, $bob, $horse, $house, $joe, $horse, $cat, $house, $shack ) = mysql_fetch_row($request);

echo '<table>
  <tr>
    <td width="20%">Name</td>
    <td width="20%">Residence</td>
    <td width="20%">Pet</td>
  </tr>
  <tr>
    <td width="20%">',$name,'</td>
    <td width="20%">',$shack,'</td>
    <td width="20%">',$pet,'</td>
  </tr>
</table>';


if it's a while loop then
while ($row = mysql_fetch_array($request)) {
echo '<table>
  <tr>
    <td width="20%">Name</td>
    <td width="20%">Residence</td>
    <td width="20%">Pet</td>
  </tr>
  <tr>
    <td width="20%">',$row['name'],'</td>
    <td width="20%">',$row['shack'],'</td>
    <td width="20%">',$row['pet'],'</td>
  </tr>
</table>';
}



is this what you are looking for?


Dempeduck

no, thanks for trying though  :P.

I guess calling it a php/sql question is whats tripping you up.  It's more of a pure sql question, I think I'll just ask someone in person where I can explain it to them, it's pretty complicated.
"You thought the leaden winter, would bring you down forever,
But you rode upon a steam to the surface of the Sun"
--Tales of Brave Ulysses, Cream

Aquilo

sorry, you mean to insert into the rows

mysql_query("INSERT INTO {$db_prefix}table VALUES ('$name', '$pet', '$residence', '$bob', '$horse', '$house', '$joe', '$horse', '$cat', '$house', '$shack') LIMIT 1");

or database structure for these rows?

Cadish

I think he wants to search for a specified value in a column... ::)

mysql_query("SELECT * FROM myTable WHERE ( residence LIKE '%house%' )" );

Advertisement: