Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Select Specific Phrase From MYSQL Database


I am working on a World of Warcraft guild's website and I am trying to create a page where players can select different kinds of gear, i.e. the gear with the most Stamina.

All the player's items are stored in the database and every item have a field in the Items-table containing the item's tooltip. This could look something like:

Boots of the Nexus Warden
Soulbound
Feet Cloth
97 Armor
+27 Stamina
+17 Intellect
Durability 35 / 35
Equip: Improves spell hit rating by 18.
Equip: Increases damage and healing done by magical spells and effects by up to 21.

I then want to select the item with i.e. the most Stamina for all the different slots; Head, Chest, Legs etc.

If I write this:
$query = mysql_query("SELECT substring(item_tooltip, LOCATE('Stamina', item_tooltip)) AS maxor FROM roster_items WHERE member_id = ེ'") or die(mysql_error());

It returns the following:
Stamina +17 Intellect Durability 35 / 35 Equip: Improves spell hit rating by 18. Equip: Increases damage and healing done by magical spells and effects by up to 21.

But I want for it to show the leading characters also (in this case "+27 " before "Stamina") and then not show anything else after the phrase "Stamina". So it shows "+27 Stamina" and nothing else for the above mentioned item. How do I accomplish this?

And then, secondly how do I then get it to show only the item with the most Stamina after it selected the above?

Hope this makes any sense.

I've tried to search these forums and found something a little along the lines of my problem but haven't been able to adjust them to my needs and I therefore need your help which will be greatly appreciated.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Select Specific Snippet Of Text, Replace With A Database Result
I'm having some problems trying to do something; I just can't think of a way to do it. Basically, I want to search for a specific snippet of text in a body of text, then replace it with the requested database result with some thrown in HTML.

Users will be able to type the following (or something along these lines, depending on what works best): [image=12345]Insert caption here[/image]

Then I need it to search for the requested image in the appropriate table and return the image's url (for an example, let's say the table is called "images", and the columns required are "imageid" and "imageurl". Code:

MySQL - Select Specific Row Based On Unique ID
I am building a photography website in html, and have a pre-formated table in which i want to put a thumbnail pic, the date of the pic, the name, and links to different sizes of the image. In a MYSQL database i have a table with four columns: ID (INT, auto-increment), ImageName (VARCHAR), FileName (VARCHAR), Date (VARCHAR).

I'm just getting started with PHP, and i want to either:

have the information automatically inserted into my pre-made table via a php loop command

or

write a script which will allow me to only enter the id# and will subsequently insert the name and the date into my table, and which might display the image of the filename.

I hope this is clear enough, I've bought quite a large book on PHP and have been browsing forums in an attempt to learn, but i can't find an example that inserts it into a pre-existing table.

How Can I Create A Random 'Phrase' Generator Without Using A Database In PHP3???
I would like to set up a rotating, random phrase generator online. I hav a list of phrases and would like them to pop up randomly as the page is loaded or reloaded...

I've played aroud with random number generators...but how would I get phrases to show up rather than numbers?

Editing Mysql Database Row With Select Box
I have a small site, this small site has a few categories, now I can add items through my online admin area fine and delete them fine, but when it comes to editting them I am having some trouble, everything is working fine except the category column, because it is a drop down box I do not know how to have the category selected during the creation progress selected all the other info is loaded.

Using PHP And MYSQL To Select From Database Using Images
I'm trying to update a main page with a list of details matching a selection from a display of images that are displayed in a small window that have been selected from an image group using a select box in the main window, however I don't know how to do this and the main page is not receiving anything when clicking on an image so it's refreshing with empty data. 

I've seen many many pages giving examples of how to do this with select boxes or how to do this if only one entry uses an image shown in the small window, but the image display window is displaying many different small images not a select box and the database itself has multiple entries that use the same image.  Can anyone help?  I have a few instant chat programs if someone wishes to discuss this with me in real-time to see what it is I'm trying to achieve.

SELECT Error: No Database Selectedin Query: SELECT * FROM Schedule
I got the above error message after reading FAQ #10 which applied to my first error. The thing is, I thought I had selected a database. This script is copied from a tutorial, and I'm just too new at this to spot my error. PHP Code:

Getting Data From A Specific Row With Mysql
I'm makin a member's area on my site with sessions, as they log in correctly the username is stored as $_SESSION['user']

what I can't work out, is how to access my table and extract data from just the row that has that username, eg

SELECT * FROM table WHERE username=$_SESSION['user']

as I'm trying to make the users be able to edit profile, upload pics etc... any idea what I'm doing wrong?

Non Case Specific Mysql
anyone know how to do a search... say for '%$search%' that would not be case specific?

Grabbing Specific MySQL Records
I have set up a target page to pull information out of a mySQL database to populate the page. The problem is that it is only pulling from the first record and not the record specified. What do I have to do to pull from a specific record? I am using Dreamweaver MX to administer the site on WinXP using PHP if that information will help.

Phrase Searching
there have been doing some reading online about search engines and site searches and stuff. I am interested in knowing if there are any good tutorials out there or anything that someone might know of that shows a good process for phrase searching on a database.


Grab Data From Mysql For Specific Date
I am trying to make some code with PHP and MySQL for displaying data from table corresponding to current server date (only field with date corresponding to server date will show on webpage). PHP Code:

Make Link With A Phrase
I would like to have some help for this:

There is any phrase like "Some text, here, #*$!, yyy aaaa"

I need to separate the words and make links, like:
<a href='Some'>Some</a> <a href='text'>text</a> <a href='here'>here</a>

Someone know any topic that explain how to do that?

How To Control Access To Specific Mysql Records For A User
I am just trying out a php form, when posted submits data to database. The system is we allow everyone to submit the form. As administrator I can view and edit the records. But whoever submits the form should be a registered user and he should be able to only view his records but not edit.

Database Value Select In Combo Box!
This function is intended to display the current database field value as selected.. along with other values as general options.

I can't figure out how to get it work. Help is appreciated!!

function retrieve_category()
{
$cat = mysql_query("SELECT category_id FROM category");
while ($current_row = mysql_fetch_row($cat))
{
$row = $current_row[0];
if ($row == $id)
{
printf("<option selected>%s</option>
",$current_row[0]);
}
else
{
printf("<option>%s</option>
",$current_row[0]);
}
}
}

Populating A Select Box From A Database
I have a subscription database that allows you to edit a subscribers data. For example, you enter a search term like "Bob" and it returns a list of everyone named Bob. You click the one you want and it goes to a subscriber detail page, where all of his data is populated to a form. You can directly edit this form and click save to overwrite it.

The only issue is the select boxes (drop downs) - say I have four options in the drop down box, red, blue, green and black. On my details page for bob I end up with five, I have those four PLUS whatever was saved for his color, so it shows up twice. If Bob is green, my select box looks like:

Green
Red
Blue
Green
Black

How can I make it so that Green only shows up once?

Select One Record From A Database
I am trying to select one record from a database. This databse has like 10 tables. I do not know which table this record is in. What php and mysql syntax would I use to accomplish this?

Randomly Select From Database?
this might seem like a stupid question, i should be able to do this. but on the front page of my site i want a thing to show a few users. but i dont want it to show the same people over and over. i want it to select different people each time. any ideas?

Offensive Word/phrase Filter
I've got a function that is being used to filter messages before they're inserted into a database that gets rid of any foul language and replaces it with either **** or an alternate word/phrase. The problem is it replaces parts of other words.

For example, the word Assault gets replaced as: ***ault. Can someone please help me modify this so it only replaces whole words? I was thinking maybe putting spaces around the word to check it, but this will cause it to fail on words at the beginning of the text or with punctuation after or around the word (like "bleep" or bleep.)  here's the function: Code:

Detect Phrase Being Repeated X Times In A Row?
Would somebody please tell me if there is a way to find out if something is repeated X times in a row in a string?

Like if X is 5 and the string is "Cows go moooooooo" then it would replace the "ooooo" after "m" with Y "o"s, like "oo" if Y=2?

Is this possible? And if it is could somebody please help me get started? I have no clue how to do this >_>

Trim() A Phrase Instead Of Individual Characters
I have a script that takes a URL and trims characters from it for storage in a database. My intention is to trim http:// from the start of the URL and and trailing slashes. For this I have been using the following:

$url = trim($url, "http://");

Unfortunately a problem has arisen in that any url's ending in .net have "t" trimmed from the end because, I realise, trim() strips out individual characters, not phrases.

Is there any way trim() can be modified to only find and remove the instance of http:// in it's entirety, and ignore single instances of the letters, or is there an alternative function I should be looking at?

Selective Echoing And Database Select
I have written a search engine for business listings for the company I work for. Each listing is in a database, and that works fine. The problem though is two-fold.

The first part of the problem is that not all listings utilise every column of the database, and this leaves gaps when echoing the results. This is not what i had in mind, Any ideas/help would be appreciated.

The second part of the problem is related to the first in that there is a link for any listing that has a website, but not every listing has a website, so every listing having a "Visit our Site" link is impractical and shoddy. Also, i'm not sure how to echo the url from the database effectively in the first place.

Multiple Select From Database Where Clause
I have a website with a database full of category names...I want to be able to chose lets say 5 of these categories and use a select from database clause where I could simply enter the category names I want to use but am not sure how I would go about doing it.

I can get the list to display just the Aprilia category using the code below:

$data1->q("SELECT * FROM categories WHERE cat_name = 'Aprilia' ORDER BY cat_name asc");

However...how could I get my site to display Aprilia, Ducati, Honda, Suzuki, Yamaha?

Tick Box, Select And Update Database.
I am trying to change the value in table with a tick box. If the tick box is selected it changes the value in the field to 'y' and if it is not selected it changes the field to 'n'.

First of all I need to bring back the current state of the field and then I need to be able to update it from 'y' to 'n' as many times as I want. Code:

Split By Spaces But Not When Phrase Is Inside Quotes...
I'm writing a function that parses a nested list string that might look
like this:
( "HELLO WORLD!" 1231231 awesome ( 1 2 ) )

I wrote the logic already and it starts by splitting the string by the
space character (or tab or newline).
ex... $tklist = preg_split("/s|
| /", $str);

This works except in the string case, where "HELLO WORLD!" should not
be two parts. How do I split by spaces but keep phrases inside quotes
in tact? Is there an easy way to do this?

Population Select Menu Using Php And Database Values
I have no idea how to go about this. so i would apreciate some help i want to populate the values in a html select menu from database values in one table

so i want all the values from 1 particular field in the database to be displayed in the select menu as separate options.

Displaying A List Of Categories From A Database In A Select Box
Could someone please tell me why this outputs nothing

<select name=categories>
<?
$cat_array = get_categories();
foreach($cat_array as $this_cat)
{
echo "<option value="";
echo $this_cat["category_id"];
echo """;
echo ">";
echo $this_cat["category_name"];
echo "
";
}
?>
</select>

==========================================================

function get_categories()
{
//get the list of categories from the database

$conn = mysql_pconnect("localhost", "user", "pwd");
$query = "select * from categories";
$result = mysql_query($query);
if(!$result)
return false;

$num_cats = mysql_num_rows($result);
if($num_cats == 0)
return false;

$result = db_result_to_array($result);
return $result;
}

//A function that returns a query to the database as an array
function db_result_to_array($result)
{
$res_array = array();
for($count=0; $row=@mysql_fetch_array($result); $count++)
$res_array[$count] = $row;

return $res_array;
}

Connecting Two Database Populated Select Menus
I am able to grab the data from the database to populate the menus individually using.
PHP Code:

Reusing An Object For Common Select To Database
I've noticed that after I finished this app, I had repeated a similar task over and over and would like to modularize it. The repeated task was connecting to the database, executing a select, putting all the results of the columns into different variables of an object. PHP Code:

Simple Filter Of Database With $_GET And Select SQL
I need help with my logic statement with a simple search engine on a MySQL table.
I have three form text input fields named f_name, l_name and dept. I am using the GET method to gather data the user enters in each input field.

So far I have been able to build a check to see that the submit has been clicked but I am having trouble with assembling the SQL statement because I need for the search engine to be able to filter the results based on the information provided in 1-3 of the fields.

I could use if statements with some and clauses but that would mean that I would have to account for each combination. Something like

If(($_GET[‘f_name’] != “”) || ($_GET[‘l_name’] !=) || ($_GET[‘dept] !=)){

$sql = "SELECT * FROM facform WHERE f_name LIKE '$_GET[f_name]',
l_name LIKE '$_GET[‘l_name]', dept LIKE '$_GET[dept]' ”;}

The problem with this is that I would have to get every combination and it’s not very scalable. How can I create this SQL statement dynamically? Code:

Error In Generating Table From Database Select Statment
I am trying to dynamically create a table with the results from a select statement. Below is the code that is not working. Any help would be oh so greatly appreciated. This is for a final at school which is due in an hour. This is the only thing I can't seem to make work. Code:

What Is Indexing In Mysql And How It Will Be Useful And How We Can Retrieve Database Content Easily From A Database Table Containing About 5lakhs Datas
I need to select data from a database table containing huge amount of
data. Now I am storing data using one primary key and I am just using
simple select statement, and this process gives me the output but it is
taking long to execute the query. As much I had heared I want to use
some indexing or cluster indexing which might help me but I am not so
familiar with these things.

Sending People To Specific Pages That Are Coming From Specific Pages...
I want to show some specific pages to people that comes to my site from
specific urls, I know the variable $_SERVER['HTTP_REFERER'] will be
used but how?

For ex if the visitor comes from a site that is like:

I want to send this person a specific.php . I used below code but not
worked:

<?php

if($_SERVER['HTTP_REFERER'] == "www.cominghost.com" ||
$_SERVER['HTTP_REFERER'] == "cominghost.com" ||
$_SERVER['HTTP_REFERER'] == "www2.cominghost.com"){

// Specific page html goes here

}
else
{
header("Location: index.php");
}
?>

This code not worked for some cases like if the visitor comes from
http://www.cominghost.com/account/targeturl.php or
http://cominghost.com/account/targeturl.php Ok I know the if statement
not working but How?

MySQL Select
Just a qucik question. I need to display everything from the table where the data is not null, apart from username, as they'll always have a username. So far I just have this, which is on the assumption they have entered their name.

$get = "SELECT * from profiles WHERE name IS NOT NULL LIMIT 30";

Is there a way I can basically make it say. Select * from profiles where * but username is NOT NULL?

Php/mysql Select
I need to retrieve the most recent additions to a table where column name='$string'
My question is that of these records returned, I need to diplay THE MOST RECENT record in one place on the html page, and then display the others (in order from newest to oldest) in another place...

I can pull the records with a select statment, and I understand the ORDER BY statement that follows, but how do I split the results as above?

** The records have a 'date/time' column, and a 'category' column that I will use to perform the select statement...**

MySQL SELECT
I have a page where I am trying to list data from a select statement. However, I am only getting one record from this SQL statement in a PHP script, but over 3200 records with the same statement in phpMyAdmin. Am I doing something wrong? PHP Code:

MySQL+PHP Select One Row
I'm sure it has been asked a thousand times before, but still:

How can I access a particular row in my MySQL table via PHP?
The background is just to update the values of one row in the table via
a html form with the old values already filled in.
What I tried so far ist sth like this:

$row=mysql_query('SELECT * FROM names WHERE ID=$entry');
for ($i = 0; $i < mysql_num_fields($row); $i++)
{
echo("<td>$row[$i]</td>
");
}

The mistake should be that mysql_query does not return a vector, but
still a table...

Does anybody have a good idea how to solve that problem?

MYSQL SELECT?
In my code I am trying to SELECT username and UsrRights When I Echo out the SQL query I do not get anything back. Why am I not getting anything echoed back? Code:

Mysql Select Via Php
Everything works. I just want to make a table of results show up in alphabetical order.

I have mysql select whole table. I want to take the mysql select and select the whole table with one field alphabetically. A to Z. How do I do this?

Select From A Mysql Table
I want to pull one field from a mysql table. How do I do that? Do I use SELECT? The field name is $sip_visitornum. And I want the last value that was inputted in to the db. I already have the code to get the visitor number but I don't know how to display data from the database properly. Thanks.

MYSQL - Select XX Months
I have a database set up, with one of the fields is a month -

"200611" = November 2006
"200610" = October 2006
"200609" = September 2006

I was wondering, I know how to sort descending etc.. - Is there a way,
to (add to an existing search criteria).. select all records in the
last XX months..

IE, If I only wanted the last 2 months, it will only select records in
October & November 2006....

or September also - if I want 3 months...

(I have records going back to April 2006)

Im guessing the 'unique' function will be used, but im not sure how to
select XX months.....

Negative SELECT In Mysql?
How does one retrieve the rows in a select statement that DONT match the
select.

select CarIndex FROM DealerCatalog, BigCatalog WHERE
DealerCatalog.CarIndex=BigCatalog.CarIndex

finds all the cars in the dealer catalog that are in the bigger distributor
catalog.

How do I do the opposite in a single sql statement i.e. all the dealer cars
that AREN'T in the big distributor catalog?

Mysql Query - Select Any
I have the following sql statemant to search a mysql database that gets
if values from a form with combo box's in.

SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid =
hottubs.manid AND hottubs.type = '%s' AND hottubs.dimlength <= '%s' AND
hottubs.dimwidth <= '%s' AND hottubs.dimhight <= '%s' AND
hottubs.seatsto <= '%s' AND hottubs.shape = '%s' ORDER BY
$thesearchtype_search.

Everything works fine except I want to add a select "any" from the
shape combo box. I really need a way of cutting out the last " AND
hottubs.shape = '%s' " if the $_GET['shape'] = 'any'
Will this work using a variable as shown below??

IF ($_GET['shape'] != 'any' )
{
$shape = AND hottubs.shape = '%s'
}

SELECT * FROM hottubs, manufacturers WHERE manufacturers.manid =
hottubs.manid AND hottubs.type = '%s' AND hottubs.dimlength <= '%s' AND
hottubs.dimwidth <= '%s' AND hottubs.dimhight <= '%s' AND
hottubs.seatsto <= '%s' $shape ORDER BY $thesearchtype_search

I have only been doing php about a month so go gentle!

MySQL SELECT Returns.
How would one go about retrieving data from a MySQL table, and then breaking it up into groups of, for example, 5.

What I am trying to do is pull search results from sed table, and then be able to have links at the bottom that would be like "<Previous 1, 2, 3, 4, 5, 6, Next>" where the numbers represent the dynamic amount of pages listing the search results.

(mysql) Select And Indices
Trying to write a php script where the user will enter the row number
(index) of a record. Say, for example, user wants record 55:

[MySQL]: select * from MyTable where Index = "55"

where Index is an autoincrement value, and also an index.

Unfortunately, MySQL barfs on this type of instruction. Doesn't seem
to want to let me access Index values...

Select Multiple & Mysql
What's the sql should look like to get all possible data when using multiple select,
such as: <select name="hostfield[]" multiple> PHP Code:

Conditional Select From Mysql
I have a mysql database which stores race data that I want to open up to users for viewing. I want the user to be able to select various subsets of the data according to the parameters: race, gender, age, and type (and maybe sometime, by name as well). This is BOTH a mysql question and a php one, as I ask for a more efficient solution (see bottom this post).

Here is a snippet of how I am implementing the mysql statements to select only the exact subset of data. PHP Code:

MySQL Select Case
I'm trying to get the venue in the 'List' column when in contains a
value. But if the venue Is Null then place the event in the 'List'

SELECT
CASE
WHEN event Is Null THEN venue
Else
event
End as 'List'
,DATE_FORMAT(fld_date, '%M') as Monthly[color=blue]
>From na_statistics[/color]

MySQL: Select Row Numbers
I would like to be able to do something like this...

select name,dob from employees where [rownum] > 10 and [rownum] < 20;

.... results from this would show me data from the 10th, 11th,... and 19th
row.

MySQL Select From (no Column)
Is it possible to select from a table using WHERE without putting in a column name? Kind of like this: mysql_query("select * from flights WHERE  LIKE '{$searchfield}'");


Copyright © 2005-08 www.BigResource.com, All rights reserved