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


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Store Result Of SELECT Stament To Be Used To UPDATE Another Table


im trying to update a field of a table which is done through the results of a select statement. I need to be able to a store the results of the select statement which can then be used to determine if an update another table is initiated. This is where i have got so far: Code:




View Complete Forum Thread with Replies

Related Forum Messages:
Select Result On Empty Table?
can't remember how to do this, doing a select on a db like so.

$query = "SELECT user_id FROM tool_user WHERE user_name = '$user_name'";
$query = mysql_query($query) or die("eek");

which will work if there is at least one entry in the database table, however how do i return a result id the table is empty? do i need to use @mysql_query($query) and then something after that?

View Replies !
How Do You Store An Sql Result In A Php Array?
How do you store an sql result in a php array? The array will hold, the following fields; itemid, itemname and itemdesc. I would then require, depending on the user selection to query the array by itmeid, and return the itemname.

View Replies !
How Can I Update/insert One Complete Table Into Mysql Table
How can I update/insert one complete table into mysql table. Input data will be from another page (a form html/php) and data will be update/insert into mysql table. table would be like this : total coloum-- 11 , total row -- 7. I want update in one go.. it may be using loop or otherwise.

View Replies !
How To Select One Row From Query Result
once the button is clicked to find an appointment the following query is executed: Code:

View Replies !
Update Table While Insert Data To Another Table
it seem like mine coding din work.
[php]<?

include("checkin.html");
$conn=mysql_connect('localhost','root','') or die ('Could not connect to server');
$today = date("Y.m.d");
mysql_select_db('hms', $conn);

$ok = mysql_query("INSERT INTO check_in(ID,room_no,datein)values ('$ID','$room','$today')", $conn);

if( $ok ){

$up = mysql_query("UPDATE studtable SET checked = 'checkin' where [ID] = '%ID');

if(mysql_affected_rows( $up ) == 1)
{
echo'Checked IN!'
}else { echo'No such student to check in' }}
else { echo'Check In FAILED, please check again'}?>[php]

View Replies !
OnLoad Update Table Depending On Y/N Value Of Another Table
I need to update a field in a table that has 2 fields:

LaptopName
StatusID

I have another table called loans, in this table one of the fields has a complete Y/N value (depending on whether the loan is complete, i.e. returned laptop to me)

i need to make it so that "Onload" the statusID   field of the laptops table is updated to "AVA" (avaliable) but only if the loan tables "complete" field is set to "Y".

How is this done please? I think through the Onload command but am unsure?

View Replies !
How To Select Count From 2ndary Table On Matches In Primary Table?
I'm coming back after about a 4 year break, so even basic stuff is taking forever to re-learn - I have a feeling that this is going to be a dumb question. Any suggestions on the best way to:

SELECT count(<other table entry id>) FROM <other table> WHERE <the entries in this table referencing other table id> = <entries in other table by other table entry id>

Basically, I just want to construct multiple rows of data that say: "here's the details of a Topic, and there are 10 (or whatever) Entries for this Topic" It seems like it should be simple enough. Code:

View Replies !
Store My Thumbnails In A Table? OR Generate Them On-the-fly?
I am making a products database for an online store. Anyway, I am currently storing images (JPG and GIF) for each product in a table. I plan on having thumbnails for the images too.

In terms of speed & system resources, what do you think would be best for me: Should I store two seperate copies of an image (full size + thumbnail) in my database? (just make two columns: one would store the binary information for a large image, another column would store the binary information for a thumbnail) *OR* should I resize the large image-on-the fly?

Basically, the first method would require resizing the image once, so our table would have slightly more information. The second method would require resizing the image every time a page is accessed, so the server would have a little extra strain put on it.

View Replies !
When To Store Content In A Database Table?
When developing a website in general when should I choose to put
content in a database. For menu options, settings, and listings like
products it seems to be clear for me to put them in. But the main
content (article for example) should I put that in a page or in the
database.

More in general, when would it benefit to use a database and
when not. Does anyone know a good tutorial or do you have advice
concerning this.

View Replies !
SELECT Result Sets 20 At A Time
This might be easy but I am trying to list result sets from a SELECT query 20 at time and I am not sure how to handle it.

I want to be able to say
'Displaying results 1-20 of 329' with a link to the next 20.

View Replies !
Getting A Specific Row From A Mysql_query(SELECT *) Result
I'm selecting a group of records from a table, then, using mysql_fetch_array() and successfully creating a table of results.  All fine and no problem.

A row in this table is a small portion of the fields from the database record, with the whole record to be displayed on an item details page via a link.

My question is: When the user clicks a link to a particular item, which will be identified by the unique id from the record, how do I query the result resource that I already have from the select query to feed that, specifc, record to the details page?

I don't want to have to re-query the database using the unique ID if I don't have to.

I understand that mysql_fetch_array just advances the array pointer along one.

View Replies !
Manipulating Result On A SELECT Query
I have the following table:

+-------------------------+
| id | tid | type | value |
+-------------------------+
| 1 | 23 | 1 | 8 |
| 2 | 21 | 1 | 6 |
| 3 | 21 | 2 | 4 |
| 4 | 21 | 2 | 9 |
| 5 | 22 | 2 | 9 |
| 6 | 22 | 1 | 10 |
| 7 | 23 | 1 | 5 |
| 8 | 22 | 1 | 4 |
| 9 | 21 | 2 | 7 |
| 10 | 22 | 2 | 7 |
+-------------------------+

and I want to get the result like this: Code:

View Replies !
Store Encrypted Passwords In A Mysql Table.
i want to store encrypted passwords in a mysql table. what is a good recommendation on how to encrypt them. currently i'm using the mysql password() function, but i'm running into problems with spaces.

if a username=test
and password=joe

it still allows password=' j o e '

with any amount of spaces ANYWHERE in the password as long as the string has the correct password text ....i.e. the j, the o, and the e in the correct order.

wtf is up with that? what the hell is the point of the password() function, if it doesn't care about spaces? am i missing something here? if i am, i would love to be helped out, otherwise i'm going to have to use a php encryption method instead of mysql.

View Replies !
Store The Entire Table In A Two Dimensional Array
I am reading info from a tab-delimited text file and I was wondering if anyone knew how to get this concept to work. I am trying to store the entire table in a two dimensional array, but the way I'm doing it right now won't work.

for($i=0; $i<$numrows; $i++)
{$columnsvalue[i] = explode(" ",$newfile[i]);}

does anyone else know how to better work with multi-dimensional arrays?

View Replies !
Using Session_id And A Sql Table To Store Each Active User?
been searching the forums for users online scripts, i got the general idea of using session_id and a sql table to store each active user (guest and member)

But is there any easier way? The thought of adding the session id onto the end of every link on the page is a bit scary.

View Replies !
Read Data From A Table In Pdf File And Store It To Database
I have to populate MySQL database where data will come from a PDF file. This PDF file has a well formatted table and I have to make a similar replica of the table data into MYSQL Database. Is that possible at all?

View Replies !
Select And Update Vs Update
For doing update or insert code, its worth noting that Example 1 seems to be around 60% faster than Example 2 PHP Code:

View Replies !
MySQL UNION: Only The First Select Statement Returns A Result.
I am attempting to join multiple select statements into a single query.
However, I am not able to extract the result of any of the UNIONED selects.











$query1 = mysql_query ("
(
SELECT SUM(deposits) AS total_deposits
FROM table1
)

UNION ALL
(
SELECT SUM(withdrawals) AS total_withdrawals
        FROM table1
)
")
or die (mysql_error());

$result1 = mysql_fetch_array($query1);
extract($result1);




When I echo the results of the second select statement I get nothing.


echo  $total_withdrawals;

View Replies !
Select Query - Count Does Not Return Correct Result
I have "enrollment" table with the following structure:

CREATE TABLE `enrollment` (
`enrollmentID` bigint(20) NOT NULL auto_increment,
`coursename` varchar(200) NOT NULL default '',
`studentID` int(4) NOT NULL default &#390;',
`semestername` varchar(100) NOT NULL default '',
PRIMARY KEY (`enrollmentID`)
)

This table is populated with coursenames that students have enrolled in a particular semester. Given a semestername and coursename, my Select query is trying to retrieve all the coursenames and count of the number of students enrolled in each of the courses for the given semester (except for the given course). Code:

View Replies !
MySQL Table To Store Username/password And Other Data For Members
I have a PERL program that uses a .db file to store username/password and other data for members. I am also going to have a PHP/MySQL based board system (phpbb) installed on the server. What I would REALLY like to do is to have users be able to register for one and be automatically registered for the other. The problem is. I don't know much about how all this works! I know just enough to get by with changing code around, etc. and also enough to screw things up now and then.;)

I could pull just the username/password data from the .db file (using a PHP script/file) and then put the data into the MySQL table used by the boards. But I'm not sure how to go about doing it, as far as the code and everything.

View Replies !
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:

View Replies !
Update Select Elements
I have a mysql table containing a list of grades and classes of a school. Now, I have a form with which one can add a student to a different table with his grade and class being determined according to the grades-classes table. I created two select lists: one for the grade and another for the class. I want that once the user has selected the grade from the first selection list he will be given the appropriate classes in the second selection list according to the mysql table.

View Replies !
SELECT And UPDATE Queries
I have the following code that displays an ad at the top of my webpage. I would like to add an update statement that updates a field in my table for the cooresponding ad whenever the ad is displayed. Code:

View Replies !
SELECT, INSERT, UPDATE
On this project I have got 2 items a mobile and simcard, these are in one table as two records and have a unique equid each. the simcard is also in another table called siminfo and has a parentid (which is the same equid as the mobile) to create the link. In the equipment table there is also userid

I already have code that transfers these items individually, but i want to be able to transfer them both when i transfer the sim card. I currently have the followin but its not working for some reason. the variable $equid does work i have tested it. This code is not picking up the simparentid though Code:

View Replies !
Select And Update In One Query
If I have a simple select query that select everthing in a row like

SELECT * FROM profiles WHERE .....

can I also make a update in conjunction with the selection? Like 'column+1' so I will get a field telling me how many times a specfic rowID has been viewed? What about speed? Is there any difference in running two queries right after each other or running one query with a combined select/update?

View Replies !
How To Store 3 Seperat Post Values Into A Time Field In A MySQL Table
I am setting up a form to except time I've set up 3 drop down boxes:

- Hour (1 - 12)
- Min (15, 30, 45)
- AM or PM

what's the best way to get these three post values into a format to store in a MySQL time field.

View Replies !
Format Table With PHP Result
I have to create some kind of dynamic page, logic is next: i have integer in variable and i need to create certain number of fields based on that int. example
$variable = 6 and I need to have table with 6 fields, 4 in one row and 2 in second....my problem is how to do that, how to get new <tr> when number in bigger than 4.

View Replies !
Saving A Result To Another Table
I have a script that will print out the results of a table and make a
calculation of a total of one of the columns. See example:

<?php

/* Database connection */
include(MYSQL_CONNECT_INCLUDE);

/* Select all pilots */
$query = "SELECT * FROM pilots ORDER BY pilot_num ASC";
$result = mysql_query($query);

/* Determine the number of pilots */
$number = mysql_numrows($result);

if ($number > 0) {
/* Print roster header
Change this HTML to fit your webpage layout */
print "<table>";
print "<tr>";
print "<td bgcolor=#000080 width=85 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>NUMBER</b></font></td>";
print "<td bgcolor=#000080 width=120 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>NAME /
EMAIL</b></font></td>";
print "<td bgcolor=#000080 width=130 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>CITY</b></font></td>";
print "<td bgcolor=#000080 width=93 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>COUNTRY</b></font></td>";
print "<td bgcolor=#000080 width=93 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>FLIGHT
TIME</b></font></td>";
print "<td bgcolor=#000080 width=75 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b><center>STATUS</center></b></font></td>";
print "<td bgcolor=#000080 width=75 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b><center>LOG
BOOK</b></center></font></td>";
print "</tr>";


View Replies !
Mysql Table Result
I have a product page which grabs a product, lets say the ID = 1. At the bottom of the page it grabs the 2 latest products created by that user. I would like it to grab the next 2 products in the database instead of the latest. So,

Product 1

Other Products

Product 5 and Product 6.

View Replies !
MySQL: Insert...select - Update?
I was reading about insert select
http://dev.mysql.com/doc/mysql/en/insert-select.html

Thought this may be a better way to perform a query I'm doing. The differenc is that I need td select from one field, and then update another field in the same record (it is a backup/undo field).

Is there a way to do this in one query? It's a large chunk of data (longtext) so I thought this would be faster than the alternative...

View Replies !
How To Update Select Multiple Menu??
how can i update the select multiple menu?? PHP Code:

View Replies !
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:

View Replies !
Create Html Table With Php Result?
I'm looking to display 5 records in one rows, from the database. What i mean is, basically, let's take the "emails" as an example. I have a table with 100s of email
addresses. Now i want to display these email addresses on a html table, but i want to display only 5 email adresses per table row, then the next 5 in the next table row and so
on.

View Replies !
Display Of Mysql Table Result...
I have a mysql table of articles with fields:

- recordID
- department
- articleTitle
- articleText

Using PHP, I'm attempting to get the results of the table to display as follows:

Department 1
- articleTitle 1
- articleTitle 2
- etc....

Department 2
- articleTitle 1
- articleTitle 2
- etc..

I figure I should use a while loop but can't figure out how to exit/reset the loop when a new 'department' is encountered in the $result.

View Replies !
Strange Result From Table Query
I have a simple query that I am restricting to the first 4 character, however instead of the first 4 characters I am getting only the characters from the end of the field.

The information in the field resembles: 4285-002

My result should be: 4285

What I am getting is: -002

The following is the code to pull the dat from field 'Dest':
    $dest=odbc_result($rs1, 'Destination');
        $deststrcount=1;
        $deststr = $dest;
        $deststr = str_split($deststr,4);
        foreach($deststr as $destv){
          if ($deststrcount<="1"){
            $desttext=$destv;
            $destnew = "DEST[1,$deststrcount] $desttext";
 
            $strcount=$strcount+1;
            }

View Replies !
Link Result Table Of 2 Queries
If I have 2 table, I can easily linked them with where something = something. But I have 2 tables that I generated from complicated queries, and now I want to link them together too with where something = something. How will the MYSQL query look like?

View Replies !
Problem Displaying Result In Table
im trying to display some data in a table (php + mysql) this is the code to create the table Code:

View Replies !
Using Record Identifier From Select In Update Query?
Just wondering if I can get a record identifier from a query. The basic idea is to process the data in a user-specified field in a user-specified table.. and write it back without modifying any other field. So the program would go something like this:

$qid=mysql_query("SELECT $field FROM $table");
WHILE ($list($field_value)=mysql_fetch_row($qid)) {
new_field = process($field_value);

and then the tricky part - how do I write back $field to $table? If I use an update query (eg: UPDATE $table SET $field=$new_field WHERE $field='$field_value') it will update all the fields where $field is $field_value.

Is there a way of getting a (unique) record identifier from the select query and using it in the update query? Since the table is user-specified, I have no way of knowing what the primary index is.

View Replies !
Loop To Select And Update Records Using Classes
I am using a group of classes to manipulate MySQL tables. I would like to be able to go through a table one line at a time to convert fields from all upper case to word upper case.

The problem I have, I think anyway, is that my result set from the first query is abandoned by the second query. I am wondering if there is an easy way around this? Code:

View Replies !
Query Result Displayed In HTML Table
I have a few queries that run fine & return the results I'm after. However I am unable to get them to display in rows/columns. I am sure that the results could be passed into a table using html.

$data_p = mysql_query("SELECT * FROM download WHERE dance LIKE '%$search%' OR name LIKE '%$search%'$max") or die(mysql_error());

This displays the results in one long list:

while (list($id, $name, $type,$size,$content, $dance) = mysql_fetch_array($data_p))    {

 echo "<a href="download3.php?id=$id">$name$dance</a></br>";
 }

Anyone?

View Replies !
Select Menu OnChange To Update Text Boxes
I've a select menu filled from mySql, So when I change the selection.. I want to change 3 text boxes also by the same row of database that is = to the row of the select menu.

So i tried a lot but failed.. cuz I cant send to javascript the updated values when the selected menu change.

View Replies !
PHP "Calender Like" Pop Up To Select Date And Store As Variable In Mysql Format?
I use to have this feature on my site about two years ago when i hired someone. It would allow the user to select between two different dates, via a small calender, save it as a variable then query the database.

Does anyone know where I can find the script for the small calender? I think it must of been populated by an external clock since all the dates were accurate etc. July 21st was on a saturday.

View Replies !
Creating Table Rows Based On Query Result
I am trying to create a simple table with a fixed number of columns (5) but the number of row will depend on the results of the query. I have tried various examples found here or there and I can't get them to work. Code:

View Replies !
Recreate The Query For Each Day In Order To Show The Result In A Table
I would like to get a count for every element filled on that day but however i am unsure how to make this query to the mysql db. for example every thing filed on a monday or for each given day of the week may be better. table field is called date and is in datetime format Y-d-m H:i:s

how would i complete this query to get it to look for each even if i had to recreate the query for each day in order to show the result in a table. PHP Version 4.3.11 being used
PHP Code:

Select count (something) as total from database where ?

View Replies !
Send Mysql Query Result Displayed In A Table
I have just created a shopping cart and I would like to send my user the receipt of there order by email. The receipt is generated by a mysql query and is displayed within a table. I have worked out how to send a html using simple HTML code as my “$messageâ€&#65533; variable: $success = mail($to, $subject, $message, $headers);

But I can not get it to send my mysql query result displayed in a table. How can i create the result of my mysql query and make it a simple variable i.e $message.

View Replies !
UPDATE To Table
I have been having problems with updating a table of mine for the past few days and cannot find a solution or reason why it is not working. What happens with the code below is a user logs in so an query is made to update their login status to 1 (0 = logged out, 1 = logged in).

Then to make sure that the update to the database is made there is a check to see if it has been changed to 1 before the page is redirected to logged_IN.htm (the code below does find $login_num = 1). The problem is that in the table after the header function is executed.

The value for login never changed to 1 in the table, it is always still 0. If I remove the header and have it not redirect to another page the login value in the table does change to 1. I have tried using 2 different servers also and still have no luck. Code:

View Replies !
Update SQL Table
I created a file that performs 3 processes for a subscription site:

Validates existing User in USER table - works
Allows user to select a new subscription rate - works
Takes user to PayPal and processes the payment. - works
Returns user to subscription site - works
Update the USER table with new subscription rate value - Doesn't work

There is one function registerUser(),but I can remove any references to that as I used the registration.php as a basis for the renew.php

I really just need assistance with getting the database to update the existing user after the payment has been processed.

View Replies !
Table Update.
I have being working with a database. I created it using a php form. it display every thing propelly using a php page, then i use the DELETE statement to empty the table and then i start adding data again. Then I did a SELECT * FROM table-name and it show everything fine but then I notice that the colum id/primary key does not start from the beginning gain so i did updated the table from the mysql command line fixing just the id columm with the righ id/primary key.

Now i do a SELECT * FROM table_name and it is updated fine, but when i run the php page that used to display everything, it does not show anything from the database. Do i have to drop the table and start all over again?

View Replies !
Update Table
I have a form which I would like to update. I want the form to display the current values in the table. Then, the person can change (type over) the existing values with new values. And then update the table with the new values.

When I run my script, I'm able to select the record I want to display. The form displays the current values of the record. When I try to change a value and click Submit, the old value keeps re-appearing. The new value is disregarded. Code:

View Replies !
Update From Another Table
I'm trying to update the value of one field (pts_ga1) with the value of a field within another table (correct_score_ga1), but the update isn't working.

$result = mysql_query("UPDATE world_cup_users SET pts_ga1='(SELECT correct_score_ga1 FROM world_cup_scores)' WHERE username ='$username'");

View Replies !
Code To Make Table Rows Of A Result Appear In Alternating Colours...
How can I get it so that when I run a search, and the results come back in table format, the rows are alternating colours, like on Devshed's forums? I believe there was some code here some time ago saying how to do it..

View Replies !
Displaying Last Result From A Mysql Table With A Limit Of 10 Results Per Page
I want to show the last post in a mysql table. And i am displaying them with a limit of 10, i.e. 10 results per page. Now i have a problem figuring it out what would be the starting point of the results display in this case. Code:

View Replies !

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