MySQL - Select Specific Row Based On Unique ID

Mar 7, 2007

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.

ADVERTISEMENT

MySQL Select Unique Values Based On One Or More Possible Clauses?

Jul 13, 2011

So there is this database table:and this array with selected options:

$options[1] = 1;
$options[2] = 5;
$options[3] = 3;

[code]...

View 3 Replies View Related

Unique Code Based On Users Unique Email Address Inserted Into Mysql Table?

Mar 15, 2011

I have a mysql table which will store users email addresses once submitted (each is unique and is the primary field) and a timestamp. I have added another column called `'unique_code' (varchar(64), utf8_unicode_ci)`.

a) Generating a 5 digit alphanumeric code, ie: 5ABH6

b) Check all rows in the 'unique_code' column to ensure it is unique, otherwise re-generate and check again

c) Insert the uniquely generated 5 digit alphanumeric code into `'unique_code'` column, corresponding to the email address just entered.

d) display the code on screen.

The table should look like:

email unique_code timestamp
test@test.com 5ABH6 2011-03-15 14:51:18
test2@test.com 9QRE0 2011-03-15 14:51:24

What code must I put and where?

My current php is as follows:**

PHP Code:

<?php
require "includes/connect.php";
$msg = '';

[code]....

View 6 Replies View Related

MySql Select Unique Rows?

Apr 25, 2005

I am have a table which contains recent search querys of another table.

I am tryng to output this data into a list so the user can click, and re-run a recent search...

The problem is that the table is full of duplicate searches from the same user.

How do I select the searches without retrieving duplicates?

SELECT id, term FROM project_term WHERE pid='$_SESSION[project_id]'

Also, would it make more sense to store all serches of a paricular user, or stop the insert if the record exists? Is there a way I can do this without performing 2 queries (ie adding some sort of LIMIT or other xeyword to the INSERT query?) I can't make the column unique because two users could perform the same search...

View 1 Replies View Related

Select A Unique Mysql Line Without While?

Mar 4, 2011

I want to select only unique values with php/mysql.

I can do it with many line, but I forget how to do it without while... :)

Here is the code that I want to do without while.

$request_1m = "SELECT date1, date2 from mytable";
$result_1m = mysql_query($request_1m,$db);
while($row = mysql_fetch_array($result_1m))
{
/* Get the data from the query result */
$date1_1m = $row["date1"];
$date2_1m = $row["date2"];
}

View 4 Replies View Related

Select All Unique Collumn Entries In Mysql

May 30, 2006

Can anyone tell me how you can query mysql for all unique entries into
a particular table collumn. Ive checked the manual but had no luck!

View 1 Replies View Related

Select A Specific Row In A Mysql Table?

Mar 18, 2007

how do I select a specific row in a mysql table?

View 5 Replies View Related

Select Specific Phrase From MYSQL Database

May 25, 2007

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 = &#3962;'") 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 1 Replies View Related

Select Specific Rows In A MySQL Table?

Jun 13, 2011

How can I select specific rows in a MySQL Table? So instead of selecting ... ORDER BY date can I do something like SELECT * FROM Posts FROM(5) TO(10) ORDER BY date DESC where I would be selecting Posts 5 to 10 in the descending order?

View 6 Replies View Related

Select Specific Content From Mysql Database?

May 20, 2011

I need to echo text from a specific ID in my table..If i use

<?php
database_connect();
$navquery = "SELECT * from content

[code]...

View 1 Replies View Related

Select A Specific Row From A MySQL Result Resource?

Feb 11, 2009

My code generates a random number and then I want to select the row from a result set corrosponding to that number.

I'm new to PHP & SQL and I can't find a way in the manual to select a specific row from a result resource, only mysql_fetch_array() which seems to just take the first row and then move some invisible pointer on to the next one.

My code looks like this, but surely there is a more efficent and elegant way?

Code:

// Loop through results fetching the first
// row until I reach the <$rndTestNo>th row
for ($i = 1; $i <= $rndTestNo; $i++ )
$row = mysql_fetch_array($result);

View 2 Replies View Related

Select Based On Path In Mysql?

Jun 13, 2011

I have a column id, a column parent and a column path that is a materialized path.It looks like

1 | N | 1
2 | 1 | 1/2
3 | 2 | 1/2/3
4 | 3 | 1/2/3/4
[code]....

View 1 Replies View Related

MySQL: Select Based On First Letter Or Number

Aug 8, 2005

I'm working with a fairly large database of company names, and I'm looking for a way to display them all in a format similar to the following:

A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|#

Click on a letter, and all companies that start with the selected letter are displayed.

I have it ALL working just fine, except for the numeric selection. Several companies start with numbers (ie. 3Com), and I would like to display all of those (0-9) when the pound symbol is clicked on. Code:

View 2 Replies View Related

Select A MySQL Connection String Based On The Value Of A Variable?

Jun 13, 2011

I would like to connect to different databases depending on the value of a variable. I was thinking of trying something like this:

if ($city = 'phoenix') {
mysql_connect("x", "y", "z") or die(mysql_error());
mysql_select_db("databasename") or die(mysql_error());
}
if ($city = 'losangeles') {
mysql_connect("a", "b", "c") or die(mysql_error());
mysql_select_db("databasename2") or die(mysql_error());
}

Is this possible?

View 3 Replies View Related

Display Results From A MySQL Database Based On The Value Of Two Select Lists?

May 25, 2011

I'm trying to display results from a MySQL database based on the value of two select lists.Here's the html I'm using for the form outside the PHP.

HTML Code:
<form id="form1" name="form1" method="post" action="<? $PHP_SELF?>">
<label>Duration
<select name="holtype" id="holtype">[code]....

However when I go to run I get the following error

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:wampwwwCaravanprices.php on line 114

View 1 Replies View Related

Unique Visits/hits To Specific Items Using Cookies/ip?

Jul 31, 2009

I use a simple MySQL table to count day hits for specific pages/items in a website. Using 'id' column for page/item ids, 'date' for the day of the visits/hits, and 'hits' column for the number of hits.Everytime someone visit the page the value of hits for that specific date is updated to +1.But, the value is updated one more time each time the page is refreshed or revisited and I need a way to save the page ID in a cookie or the visitor IP in the database to update the hits just one time.I never worked with cookies so I dont really know how to do it and the limitations of the data than can be stored in a cookie.I think saving the IP adresses of the visitors in the database is a really waste of queires and bandwitch and I read that its not always possible to get the real IP and this can make some problems and some hits not updated.I also read that its better not to use GLOBAL variables too much...

View 1 Replies View Related

Generating Specific Unique Random Alphanumeric String?

Dec 29, 2009

I want to generate a unique alphanumeric string having specific length and having specific characters used. For example I want to create random string having several alphabets initially then some numbers then some alphabets again.

e.g. (LETTER,NUMBER,LETTER,LETTER,NUMBER(A2EU7).

View 1 Replies View Related

Uniqueidentifier - Unique ID Based On Username / Email

Mar 29, 2011

I have an email address and I want to create a unique ID based on it, so say email is [URL]... that turns into 66wyy7eu. Ive found a close solution [URL]... but it needs the input to be numeric

View 6 Replies View Related

SELECT UNIQUE

Jun 23, 2005

I'm running a query which currently outputs all the dates in a field, how do I display non-myltiple dates, that is is a date is output, no dupliccate of it woldbe produced. SELECT UNIQUE date from activity.

View 2 Replies View Related

Create A Unique Session Based On An Existing Variable?

Jan 28, 2011

I'm trying to create a unique session depending on a customers ID.

session_start();
$_SESSION['ORDER$customer_id']="xyz";

However, whenever I access the session, I get the same data regardless of the $customer_id.

View 3 Replies View Related

Select A Unique String

Sep 29, 2006

I've got a field in my MySQL DB which has a user ID or their IP. I want to select the last 5 rows which has it's own ID or IP Code:

View 8 Replies View Related

Select Unique Combination

Jul 13, 2005

I want to find unique combination of two fields in a table, I tried either this:

SELECT distinct(field1), distinct(field2)
FROM `someTable`

SELECT distinct(field1, field2)
FROM `someTable`

View 3 Replies View Related

Only Selecting One Unique Object On SELECT

Oct 17, 2007

I'm in the middle of working with an auto complete script for a tag field. At the moment when doing a 'select tags from table' (to populate the array which feeds into the auto complete script) I might get results like this: Code:

View 2 Replies View Related

How Do You Select Unique Instances Of A Field Entry?

Jun 18, 2002

If I want to select and display the 'county' field from a table for all records, I'll get a list of records, many of them repeated.

How do I select and display only one instance of each record, effectively cutting out all the duplicates?

View 6 Replies View Related

Select Unique Visitors Per Date Interval?

Jun 30, 2011

I've found a few query strings related to what I'm looking for, but nothing that does this. Basically, I have a graph that needs to display unique visitors per time interval (hour, day, month, or year). So, a graph similar to Google Analytics or this Analytics Graph. The table has a visitor ID column and a timestamp column (in the style 0000-00-00 00:00:00). I need to be able to select the unique or total visitors per interval (eg. 32 visitors on the 5th, 30 on the 6th, etc). I guess my question is, is there anyway to do this efficiently with just a query? Or will I need to use PHP to get all the data (problem with that is that I would have to do a query for each point on the graph, not efficient)?

View 3 Replies View Related

Design - Use Script To Show A Unique Header IMG Based On Path On A Drupal Website?

Jan 15, 2011

I have a Drupal site that needs to display a unique header image based on the path. I have found some helpful code. It gets me close to where I need to be, but not all the way. I have pasted it at the end of this post. The issue I am having is that it bases the banner image off of the characters after the first "/" after example.com in the URL. For example, example.com/forum returns a banner of header-FORUM.png.

I need it to work a little differently. I would like it to base the banner returned off the characters after the second "/" after example.com in the URL. For example, [URL] should return a banner of header-TERM.png. Here's the code I mentioned earlier via AdaptiveThemes (FYI, there is a comment on that page that attempts to solve a similar issue to mine but I can't get it to work).

<?php
// Return a file based on the URL alias, else return a default file
function unique_section_header() {
$path = drupal_get_path_alias($_GET['q']);
list($sections, ) = explode('/', $path, 2);............

View 3 Replies View Related

Pull Unique Key Names From Json Data Like SQL Select Distinct

Mar 9, 2011

I have the following json data:

[code]...

The idea here is that I want to take this data and use parts of it. I want to create a list of the "category's" that are in the data. The problem is that there is and will be multiple items with the same category. So my list will have duplicates that I do not want. The following is how I am getting the data and converting it for use:

[code]...

So I guess muy question is I want to take the $likesArray and pull out all the unique Data->Category->names. Also will want to do sorting, and other things but I will get to that when the time comes.

View 1 Replies View Related

Get Sql Result Based On A Specific Subpage Id?

Sep 8, 2010

I am trying to get sql result based on a specific subpage id and also using the like. The subpage id does not seem to work and have tried to different codes below.

Code: [Select]$sqlItem = "select * from tblsubpage WHERE subpageid='5' || title like "%".$searchfor."%" || paragraph like "%".$searchfor."%"";
and also tried
Code: [Select]$sqlItem = "select * from tblsubpage WHERE subpageid='5' AND title like "%".$searchfor."%" || paragraph like "%".$searchfor."%"";

View 3 Replies View Related

Query Mysql Based On GPS Latitude And Longitude Columns Based On Relative Distance

Jun 10, 2011

In an app I'm building, One of the features i'd like users to be able to discover people around them easily. I'm using the GPS to get the latitude and longitude, then storing that information in the mysql db along with the other user information under a column for latitude and another with the longitude. What's would the best practice be to do a query that looks at the person whos making the query's information and then have it find the closest possible relatable lat and longitude then start there and limit it to 24 results? And furthermore, how would I remember where it stopped so I could allow another query to start where it left off and return more getting further and further away.

Basically, to generalize how can I do a mysql query that starts as close as it can to 2 latitude and longitude points that I supply and then have it grab the next 24 sorted by closest to furthest? I feel like its going to be hard to do because its being based on 2 columns. Is there a way I should/could be combining the GPS values into 1 column so it will be easy to find relative distance? Maybe I could somehow get the zip code (but then that might cause non US problems). I'm not sure. I'm stuck. If anyone has any experience on this, or is a MySQL Master

View 3 Replies View Related

Stripping Out Specific Tags Based On Attributes?

Aug 21, 2009

This is a toughie. Let's say I have a string of html that contains several nested spans. I need to completely remove just some of the spans, based on their specific attributes:

Code:

<span style="text-decoration: underline;">
<span style="font-size: small;">Earlier this month</span></span>
<span style="font-size: small;"> (“ObamaCare as a Moral Clunker</span>
<span style="font-size: small;">”</span>

[Code]...

In the above example, I want to remove any spans that have a style of "font-size: small", but leave any other spans.

I've been playing around with DOMdocument, but I can't figure out how to get it to work -- all my objects are empty.

View 13 Replies View Related

Find A Specific Day Of Week Based On A Date?

Jul 4, 2011

I would like to be able to find the date which "Sunday" falls on for a given date, formatted as YYYY-MM-DD.

... How would this be achieved in PHP?

View 4 Replies View Related

Stripping Specific Span Tags Based On Their Id?

Nov 22, 2009

Is there a way of removing a span from a string of HTML by using it's id? I have this string:code: [Select]$string='<span id="1">test string</a><span id="2">test string2</a>';I would like to be able to dynamically remove the html from one or the other tag depending on the user input, which relates to the id.

I have tried where commands relating to the id, but it's just not the same as SQL.

I'd like something like this (I know the code doesn't work... but you get the idea):

Code: [Select]strip_tags($string, where(id=$user_input))

View 4 Replies View Related

Display Specific Pages Based Upon Date?

Mar 2, 2010

First off, im very new to php, so feel free to rip me a new one if I say something stupid.I did a search but didn't find what I was looking for, or I didn't ask for it the right way.I have a php-based membership site that I want to add a monthly section to.Within the php of the site, there is already a variable that shows their join date.What I would like to do is have some sort of switch statement that compares their join date variable to the current date, and displays a different page depending on how many months or days have gone by since they joined.Basically the affect I'm after is this(obviously this is not code of any sort).

"current date" minus "join date" = XXX
if XXX under 30 days display : first_month_content.html
if XXX between 30-60 days display : second_month_content.html

[code]...

View 1 Replies View Related

Select Specific Id's

Jun 15, 2004

here is the deal I want to select specific id's from a database table. how?

<?
include($_SERVER["DOCUMENT_ROOT"]."/mundus/include/dbconnect.php");

$id = ("7" "9");
$query = "SELECT * FROM links WHERE id = '$id'";
$resultaat = mysql_query($query);

# display results
while ($data = mysql_fetch_object($resultaat)) {
$sitename = "$data->sitename";
$siteurl = "$data->siteurl";

echo ("<A HREF='$siteurl' target='_blank'>$sitename</A><br>
");
}
?>
above doesnt work though...

View 1 Replies View Related

Display A Custom Profile Based On A Specific Role?

Aug 3, 2010

For example I have a role called "teachers". For any user that belongs to that role, I want to be able to display a custom profile that is different then the main one. I read at some place that one can make a tpl file in the pages folder of the theme and some how it could be made to show for specific roles or URL path.

View 2 Replies View Related

Split An Array Into Sub-arrays Based On Specific Values?

Mar 4, 2011

I have an array as shown below, what i wanted to do is, create multiple arrays based on the datepart like(2011-02-04):

Array
(
[0] => Array
(
[avgvalue] => 0
[maxvalue] => 0

[Code].....

The above list is of array. It has timestamp key, i exploded the timestamp key so that i got date and time part seperate, now i am having problem splitting the array into sub-arrays. What i wanted was to have one array for 2011-02-04 (containing all the values for that date) and another array for 2011-02-05 (containing values for all that date). This can be dynamic, i mean the dates can be even more. So, how can i do that.

I want it as:

array[0] => array(... list of all the values for 2011-02-04),
array[1] => array(...list of all values for 2011-02-05)

View 1 Replies View Related

Include A Specific Form Based On A Record Field?

Oct 6, 2009

I have a newbie question, not sure if I am going about this the right way. I'm creating a web interface in Dreamweaver CS3, using PHP and MySQL. We are tracking different types of activities, and based on the activity type, the user has to answer a series of questions (different questions for each activity type).

I have the following tables set up:

ACTIVITIES
- activityID
- activityTypeID
- activityName
- activityDescription

[Code]...

I have a detail page that displays info about a selected activity (activity name, type, description). I would like to display the questions form on this page, based on the activity type. What is the best way to do this?

View 2 Replies View Related

Regex To Get Specific Data From A String Based On Preceding Text And <br>?

Jun 19, 2010

I have the following string example:

PASSWORD = dsl3£$Roid
dfdfdf
fgdgfdfg


its stored in MySql Text field.I need to get the "password" ie dsl3£$Roid

Its preceded by PASSWORD = and there is a line break after. I can use nl2br to make the string like this:

PASSWORD = dsl3£$Roid<br>
dfdfdf<br>
fgdgfdfg<br>

Been fighting with preg_match all day but no luck... Currently have 10k + rows, each with unique passwords and need some code to pull just the password.

View 4 Replies View Related

Possible To Show A Specific Form Field Based On A Users Input?

Nov 16, 2009

If I want to ask the user if there inquiry is for an interior or exterior job. Can i do this without showing all the form fields initially? Can I ask the question:interior or exterior? Then based on the answer display the appropriate form fields?

View 7 Replies View Related

Pull Rows From A Table Based On The Contents Of Specific Fields

Aug 4, 2010

I'm having a weird issue in which i'm trying to pull rows from a table based on the contents of specific fields. My query strings are:

$ms = ("SELECT * FROM games WHERE game = 'test' AND playername = '$test' OR opponentname = '$test' ORDER BY playdate DESC LIMIT 25") or die ('Error: '.mysql_error ());

Which works fine until later I try to use:

$ms2 = ("SELECT * FROM games WHERE game = 'test2' AND playername = '$test' OR opponentname = '$test' ORDER BYplaydate DESC LIMIT 25") or die ('Error: '.mysql_error ());

What is weird is on $ms2 I found if I change it to: $ms2 = ("SELECT * FROM games WHERE playername = '$test' OR opponentname = '$test' AND game = 'test2' ORDER BYplaydate DESC LIMIT 25") or die ('Error: '.mysql_error ());

It works... on one page, on the rest neither line works it just pulls every row in the table that fit one of the two name fields.

View 2 Replies View Related

New User Registers - Create A Unique User Page Based On Username?

Jun 23, 2009

First step, the user will register. He will put in username, Password, Address, Email and etc.. Then, once he registers, It will create a unique page for him on my domain name. For example, if the user puts /davis as his username, php will create a page on [URL]. and it will display all his details at [URL]....

View 1 Replies View Related

Use The Select Menu Value In The Specific DIV JQuery?

Jun 3, 2011

I have the following code to get the selected item value and post it to a DIV. That is okay, it is working fine, my DIV shows the selected value. But my question is how can I use that value in the DIV ? so that I can create a php msyql query.

<head>
<style>
.response {
padding:10px;
[code]....

View 3 Replies View Related

Read A Csv File, And Then Select One Specific Value?

Nov 1, 2010

I'm a newbie learning php, so please keep that in mind.

1st Question
I need a php script that reads a csv file.

2nd Question
How do I echo a specific cell (row and row/column) in that file

I found this script on a similar reply, the script reads the whole file perfectly, but I only want to select a specific cell/value on that csv file. So how do I echo a specific row or a row and column.

$row = 1;
if (($handle = fopen("1.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>
";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />
";
}
}
fclose($handle);
}

View 1 Replies View Related

Select Specific Text In Textbox?

May 11, 2011

is there any way to select the specific text of the textbox using jquery or javascript.

View 1 Replies View Related

ADVERTISEMENT