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.

View 1 Replies


ADVERTISEMENT

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

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

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

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

MySql Select Unique Rows?

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

Select A Unique Mysql Line Without While?

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

Select All Unique Collumn Entries In Mysql

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

Select A Specific Row In A Mysql Table?

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

View 5 Replies

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 = &#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

Select Specific Rows In A MySQL Table?

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

Select Specific Content From Mysql Database?

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

Select A Specific Row From A MySQL Result Resource?

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

Select Based On Path In Mysql?

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

MySQL: Select Based On First Letter Or Number

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

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

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

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

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

Html - Populate A Second Select-tag With Options Based On The Option Selected In The First Select-tag?

I will draw the options for the second select-tag from a database.

View 4 Replies

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

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

Generating Specific Unique Random Alphanumeric String?

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

Uniqueidentifier - Unique ID Based On Username / Email

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

SELECT UNIQUE

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

Create A Unique Session Based On An Existing Variable?

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

Select A Unique String

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

Select Unique Combination

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

Only Selecting One Unique Object On SELECT

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

How Do You Select Unique Instances Of A Field Entry?

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

Select Unique Visitors Per Date Interval?

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







Copyrights 2005-15 www.BigResource.com, All rights reserved