Loop PHP through 2 tables of MySQL?
Manu chaps,
I have a bit of PHP code, that loops through a table MySQL (jobs) and displays all the records that were not complete. The code and the MySQL Query work fine.
I want to know is whether the query can be modified to perform a loop on 2 tables.
Here's my current query:
@mysql_select_db ($database_conndb2, $conndb2);
$query_rsJobs ="
SELECT
tbl_projects.projID,
tbl_projects.projtitle,
tbl_jobs. JobID,
tbl_jobs. FK_projid,
tbl_jobs. JobName,
tbl_jobs. FK_langid,
tbl_languaget.langtname,
tbl_jobs.jobpages,
tbl_jobs.jobshipped
Of
tbl_projects
JOIN IN-HOUSE
tbl_jobs
ON tbl_projects.projid = tbl_jobs. FK_projid
JOIN IN-HOUSE
tbl_languaget
ON tbl_languaget.langtid = tbl_jobs. FK_langid
WHERE
tbl_jobs.jobshipped =' no
ORDER BY
FK_projid ASC";
$rsJobs = mysql_query ($query_rsJobs, $conndb2) or die (mysql_error ());
$row_rsJobs = mysql_fetch_assoc ($rsJobs);
$totalRows_rsJobs = mysql_num_rows ($rsJobs);
Here is my table that displays the results:
< table >
< b >
Title of the Document < td > < table >
Language < td > < table >
< Table > < td > pages
Edit < td > < table >
Delete < td > < table >
< /tr >
<? PHP
$previousProject = ";
If ($totalRows_rsJobs > 0) {}
Show if recordset not empty
While ($row_rsJobs = {mysql_fetch_assoc ($rsJobs))}
If ($previousProject! = $row_rsJobs ['prices']) {}
for each project, see the project ID
? >
< b >
< td > <? PHP echo $row_rsJobs ["PROJID']? > < table >
< /tr >
<? PHP $previousProject = $row_rsJobs ["PROJID"]; } ? >
< b >
< td > < a href = "jobsheet_details.php? id = <?" PHP echo $row_rsJobs ["IDTravail"];? > & amp; proj = <? PHP echo $row_rsJobs ["PROJID'];? > "> <?" PHP echo $row_rsJobs ['jobname'];? > < /a > < table >
< td > <? PHP echo $row_rsJobs ["langtname"];? > < table >
< td > <? PHP echo $row_rsJobs ["jobpages"];? > < table >
< td > < a href = "jobsheet_edit.php? id = <?" PHP echo $row_rsJobs ["FK_projid"];? > & amp; job = <? PHP echo $row_rsJobs ["IDTravail"];? > "> edit < /a > < table >"
< td > < a href = "jobsheet_remove.php? id = <?" PHP echo $row_rsJobs ["FK_projid"];? > & amp; job = <? PHP echo $row_rsJobs ["IDTravail"];? > "> delete < /a > < table >"
< /tr >
<? PHP} while ($row_rsJobs = mysql_fetch_assoc ($rsJobs));? >
<? PHP} / / show if recordset not empty? >
< /table >
And finally, this is the query that I need to add to my current request to show the resutls of the two tables:
@mysql_select_db ($database_conndb2, $conndb2);
$query_rsJobTrans ="
SELECT
tbl_projects.projID,
tbl_projects.projtitle,
tbl_jobtransline. JobID,
tbl_jobtransline. FK_projid,
tbl_jobtransline,
tbl_jobtransline. FK_langid,
tbl_languaget.langtname,
tbl_jobtransline.jobpages,
tbl_jobtransline.jobshipped
Of
tbl_projects
JOIN IN-HOUSE
tbl_jobtransline
ON tbl_projects.projid = tbl_jobtransline. FK_projid
JOIN IN-HOUSE
tbl_languaget
ON tbl_languaget.langtid = tbl_jobtransline. FK_langid
WHERE
tbl_jobtransline.jobshipped =' no
ORDER BY
FK_projid ASC";
$rsJobTrans = mysql_query ($query_rsJobTrans, $conndb2) or die (mysql_error ());
$row_rsJobTrans = mysql_fetch_assoc ($rsJobTrans);
$totalRows_rsJobTrans = mysql_num_rows ($rsJobTrans);
? >
I don't know if it's possible and tried it myself but seem to get a little bit of mess, since both tables use a foreign key to the projects and language tables, any help would be most appreciated!
Add tbl_jobtransline to the query and join the other two tables? What exactly is the problem?
Tags: Dreamweaver
Similar Questions
-
Is it possible to write code that loops through a table in a form? I am currently writing separate sections of code for each row in a table of five rows to validate the data entries.
Hello
It would be easier if your table contained a line that repeats with an initial count of five (defined in the binding of the object palette tab). This will change the XML that is generated, but assuming that it is not a problem your could loop so your table with the code;
lines of the var = this.resolveNodes ("Table1.Row1 [*]");
for (var i = 0; i)
{
currentRow var = rows.item (i);
.
.
.
}
If you don't need the lines of uniquely named then go I and the result of "this.resolveNodes("Table1.Row"+i)" in a function.
You back form... with only the first validation converted to the new approach.
https://Acrobat.com/#d=akb0 * Ptvdr3KSYN0VP * 7zA
Hope this gets you started.
Concerning
Bruce
-
I received an email indicating that HP does not show me as having all printers which explains why I have not received information of driver update I guess. But when I typed in HP4500 G510, I received the following error message:
Unable to connect to the local MySQL server through socket ' / var/lib/mysql/mysql.sock' #2 #.
And since I don't know beans about computers, I don't have any idea what it means.
Because I had to pick a topic, I chose the one above, but no other choices were nowhere near cover.
Hi mac64.
I understand you are trying to register for updates for your Officejet 4500. I can certainly help you with this.I'll give you a link to try to register for driver updates. Please let me know if it's the same link you used and if this works differently for you, simply click on the following link: the HP driver updates.
Hope to hear from you soon
-
How can I activate the FREE option of DATE for the Service of Table of MySQL?
Thank youYou can enable by default on Metrology for resources in one of the following two ways:
Individually by clicking on the 'Metric data' tab next to the tab indicators when you view monitoring data. From here you can ' metric Show more "and select the settings that you want.
In the world by going to Administration in the header, and then "followed by default. Find the MySQL Table service that interests you and click on "change the metric models." From there, you will present a similar screen that will apply to any changes to all existing and future of such resources.
-Ryan
-
How to import the selected tables from MySQL to Oracle
Hello world:
How can I import tables from MySQL to Oracle? I have more than 180 tables in my DB (MySQL), but I copy only 12 of them to ORACLE... rigth now I do it manually, using SQL Developer (rigth clicking on the picture icon and copy to Oracle) but now I need to do this automatically every 4 hours...
I read on the dblink option, but I don't know if this is the best for this case...
I appreciate all help.
Best regards
JackHi Jack,
I think that with a db-link you can define an automated task (PL/SQL + programmer).
We use a db-link to Oracle's RDBMS to MySQL. So we have no experience.
We have created the db-link like http://www.pythian.com/news/1554/how-to-access-mysql-from-oracle-with-odbc-and-sql/Heike cordially
-
CFScript to create tables (using MySQL) and configure it to use InnoDB
I use a cfscript to create my database and the tables using MySQL, and I was able to DO this with success, accept that I'm having a problem. I want to put my tables use InnoDB instead of MyISAM. How to do this?
That's what I did:
< cfquery = 'test' datasource name = 'mydatasource' >
CREATE TABLE Test
(
Id int (11) NOT NULL auto_increment,
Name varchar (20) default NULL,
Tinyint (4) active default NULL,
PRIMARY KEY (Id)
); ENGINE = InnoDB DEFAULT CHARSET = latin;
< / cfquery >
But when I get an error when I run this script. That's what I get:
-You have an error in your SQL syntax; "check the manual for your version of the MySQL server for the right syntax to use near '; ENGINE = InnoDB DEFAULT CHARSET = latin1'.
I look and it's the right syntax. Any ideas what I am doing wrong?
Thanks for any help
AlfieNevermind, I figured it. I misspelled it.
ENGINE type = InnoDB... must be before the semicolon.
:)
-
To loop through the table (newbie question)
Hello
I've read and read but can´t seem to do what I want to do.
I do a lot of forms in Livecycle, but can´t seem to understand even the easiest loop.
Let's say I have a table with two columns and ten rows. TextFields in column A is called Cell1 and Cell2 B column.
I want to look through all the lines for that:
If (Cell1.rawValue! == null)
Cell2.fontcolor = "255,0,0";
on the other
Cell2.fontcolor = "0,0,0";
If anyone can help me with this, I would be very happy. Mayvbe I can begin to understand this, because it seems that I m missing certain functions very practices.
/ Anders
Sweden
Assuming that all your lines are named 'Row ':
for (var a=0;a
Kyle
-
Can I use a username of the php session to select a mysql table?
In my site, I have a situation where
$_SESSION ['MM_Username"]
will be the same name as a MYSQL table prepared.
(There will be a limited number of users and tables)
Instead of writing a long series of "else if" to deal with each user of each page, I want to use the $_SESSION ['MM_Username'] to point to the correct MSQL table.
For example
<? PHP $query_rstPalabs = "SELECT * FROM patricia WHERE YesNo > = 1"; ? >
How can I replace the $_SESSION ['MM_Username'] for 'patricia' here in a way that the SQL would choose the table 'patricia '?
Please be aware that I am not a professional designer and wading in the shallows of PHP/MSQL. I use DW2004MX to help.
Thank you.Smiffy47,
Assign a variable with $_SESSION ['MM_Username"]. Call the variable in your query:
Example:
$user = $_SESSION ['MM_Username"];
$user WHERE yesno >= 1" ; =""?>
Be sure to use session_start at the beginning of your page so that you are allowed to call session variables in your application.
This should be added before your declaration DOCTYPE (the very beginning of your page).
-ST
-
creating a procedure loops through a table to see if the item exists
I have the following table_one created
TYPE_ID descriptiom used_value
CBX 0 Red
Boo Green 5
AAA yellow 0
Okay, I don't know how possible it is but I'm doing the following
procedure recent_change (type_required in varchar2, varchar2, value_required in description varchar2) IS
type_required varchar2 (30);
Description varchar2 (30);
value_requiredid: = to_number (value_required);
slider c3 is
Select used_value from table_one
When type_id = type_required;
Begin
Open c3;
extract the c3 in value_requiredid;
Close c3
If
<... .This is where I'm stuck >
< however, what I'm trying to do is loops through all the rows of the table to check if the description passed as parameter exist in the table (table_one) and if so, I should be able to do the following command below
Update table_one
Set used_value = value_requiredid
When type_id = type_required;
ElseIf <... . If there is no such thing as the description passed as a generally >
can do
insert into table_one (type_required, description, value_requiredid) values;
commit;
End recent_change;
I'm still a beginner so I need a little help. Thank you.I still don't know if it's possible in sql or not.
Sure. You just need to change the MERGER a little so that it matches on type_id AND description. However, you can only change the used_value now. It is not valid to change the columns that you are matching.
SQL> select * from table_one; TYPE_ID DESCRIPTIO USED_VALUE ---------- ---------- -------------------- cbx red 0 boo green 5 boo red 0 boo yellow 0 cbx green 3 cbx yellow 0 aaa yellow 0 SQL> create or replace 2 procedure recent_change (p_type_id in varchar2 3 ,p_description in varchar2 4 ,p_used_value in number) IS 5 begin 6 7 merge into table_one t 8 using (select p_type_id type_id 9 ,p_description description 10 ,p_used_value used_value 11 from dual 12 ) p 13 on (t.type_id = p.type_id 14 and t.description = p.description) 15 when matched then update set 16 used_value = p.used_value 17 when not matched then insert 18 (type_id, description, used_value) 19 values 20 (p.type_id, p.description, p.used_value); 21 end; 22 / Procedure created. SQL> exec recent_change('boo','red',1); PL/SQL procedure successfully completed. SQL> exec recent_change('cxx','green',6); PL/SQL procedure successfully completed. SQL> select * from table_one; TYPE_ID DESCRIPTIO USED_VALUE ---------- ---------- -------------------- cbx red 0 boo green 5 boo red 1 boo yellow 0 cbx green 3 cbx yellow 0 aaa yellow 0 cxx green 6
-
To loop through the table and use the values returned in another query
Hello
I tried to do something very simple, but still can not.
I am trying to iterate on a table and use each line of a column in a where clause to display a query clause.
For example:
I want to retrieve all users of dba_users pass it to a clause where clause in a query to show for example account_status and profile of each user. But I want to do it in a way if I can turn the result in an html table.
I tried too much really, so I'll post something that does not work, but which I think will show the problem I have,
BEGIN FOR i IN (SELECT username from dba_users order by 1) LOOP EXECUTE IMMEDIATE 'select account_status from dba_users where username like ''||i.username||'''; END LOOP; END; /
Example of what I want to achieve:
Suppose that there are two users, SYS, and SCOTT:
USERNAME PROFILE ACCOUNT_STATUS ------------------------------ ------------------------------ -------------------------------- SYS DEFAULT OPEN USERNAME PROFILE ACCOUNT_STATUS ------------------------------ ------------------------------ -------------------------------- SCOTT DEFAULT OPEN
Thanks in advance for your time,
OD
Hi Bill,
Bill Citad kirjoitti:
What a join or a sub query going to help me? honestly
-- join select s.sql_id, h.loads_total from dba_hist_sqlstat h join v$sql s on ( h.sql_id = s.sql_id ) where rownum < 3 ; -- subquery select sql_id, loads_total from dba_hist_sqlstat where sql_id in ( select sql_id from v$sql where rownum < 3 ) ; -- correlated subquery select sql_id, loads_total from dba_hist_sqlstat where exists ( select null from v$sql where sql_id = dba_hist_sqlstat.sql_id ) and rownum < 3 ; -- lateral inline view (12c) select s.sql_id, h.loads_total from dba_hist_sqlstat, lateral( select sql_id from v$sql where sql_id = h.sql_id ) s where rownum < 3 ;
-
Hello
There are two text fields (employee and his team). I want the team in autopopulate employee using a table (I think it's the best way).
textfieldA has 1 email in (of possible 60). I want textfieldB to autopopulate with another email (out of a possible 5), based on the rawValue of textfieldA.
My code is on a change event and looks like this (and does not):
var x;var 3dClos = new Array ("[email protected]","[email protected]","[email protected]" ");
If (email.rawValue = {3dClos [x])}
supemail.rawValue = " " [email protected] ";
}
on the other
{
supemail.rawValue = "";I don't want to make a giant if else statement as I have in the past - it's the perfect opportunity to learn the smart way to do (even if it does not use a table). So in conclusion - check an email, see if it belongs to a tema and display this email from the team in another area.
Can anyone help?
Hello
(1) if(email.rawValue = 3dClos[x])
you do transfer instead of equalization, replace it
If (email. RawValue is 3dClos [x])
(2) var x; is not initialized years you have to do the loop like this:
var 3dClos = new Array ("[email protected]", "[email protected]", "[email protected]" ");
for (var i = 0; i)<3dClos.length;i++ >3dClos.length;i++ >
If (email.rawValue is {3dClos [i])}
supemail.rawValue = "[email protected]";
}
on the other
{
supemail.rawValue = "";}
}
ARO
Paul Butenko
-
Drop into the PHP code to connect using MySQL and MyAdmin
This code should be as common as dirt, but I need help in looking for it. Considering how most of the sites have a mode of connection it surprises me that DW does not have some kind of widget to encode the fundamentals, but I digress. I have a family site private, accessible by a username / password to a file static login.php. I think of moving to the next level will require the use of MySQL and a database... which seems a bridge too far... However, what I "think" I want to do is... (especially #5)
- a login for predefined members (40 odd) system using a primary e-mail address as ID.
- a connection that has a remember me option
- a connection that would show the user the last time that he / she has logged in and how many times.
- a method of sending an email with the username and password of the user
- a method of object defining his username and / or password.
- When changes are made an email is sent to me
- and... possibly different access levels / permissions, as in, shareholder have full access and no shareholders / clients have access to only a few pages.
Can point to a location that would have such a code available for a cut and paste the developer... with instructions
Thank you for your time.
Ralph3616 wrote:
- / * Adds a line of [] $authorization for each pair of login/password you want to add: * /.
- [$authorization] = array ('feldon', '123456', ' feldon @google.com ');
- [$authorization] = array ('ralphv', '1234only', ' [email protected]');
- [$authorization] = array ('guest', '1234guest', ' [email protected]');
(How?)
- Check if the email address exists and if so
- Send an email to this address with the user name and password on this line. And a brief message... "xxxxxx xxxx xxxx" and a subject heading.
- Otherwise, a different error message on any match and contact [email protected]
A second page (the result of a failure, login) would have access to my login.php to find the desired information?
I could make a file (database?) on my server with this list?
Could this work? Can someone show me how?
Thank you for your time.
Here's one way you could do it, BUT it seems a lot of work if you have dozens of users - why your passwords/user names contained in the bays and not a database?
In any case taking the 3 examples you gave above, and assuming that you have sent your username to a 'recover' username and password ' page that has a form on it asking the the e-mail address of the user (gives the name of "email_address" entry field and then submit directly to the next page) : it grabs the value of the field in the form email_address and then checks through the berries if the email address exists. If he sends the user name and password to this email address.
I guess it's a site of low security keys so that you need not md5 passwords.
NOTE PLEASE I HAVE INSERTED AN "X" IN THE E-MAIL ADDRESSES WHICH NEEDS TO BR REMOVED. (SPAM)
<>
$email_address = $_POST ['email_address'];
[$authorization] = array ('feldon', '123456', ' [email protected]');
[$authorization] = array ('ralphv', '1234only', ' [email protected]');
[$authorization] = array ('guest', '1234guest', ' [email protected]');
{If (in_array ($email_address, {$authorization [0]}))}
$username = "feldon.
$password = "123456".
$email = "[email protected]";
$matchFound = 'success ';
}
{If (in_array ($email_address, {$authorization [1]}))}
$username = "ralphv";
$password = "1234only";
$email = "[email protected]";
$matchFound = 'success ';
}
{If (in_array ($email_address, {$authorization [2]}))}
$username = "guest";
$password = "1234guest";
$email = "[email protected]";
$matchFound = 'success ';
}
{if (isset ($matchFound))}
$to = $email_address;
Object
$subject = "Your user name and password";
$headers = "from: $email_address\r\n";
$headers. = "reply-To: $email_address\r\n";
build the message
$message = ' username: $username\n\n ";
$message. = "password: $password\n\n";
mail ($ $subject, $message, $headers);
ECHO "we sent you an email with your username and password';
}
else {}
echo "no user leaves with the e-mail address provided.
}
?>
-
Using createTextField in a loop to create a table
Hi, I was looking everywhere and through my book, trying to find a way to make a table of textfields. I have 3 tables that are received through a Pearl script and need to create a table to display the 3 tables. The size of the tables always varies the table must be able to adapt to the size.
I was thinking something in the sense of
This.createTextField("hello_txt",0,10,10,100,20) ("title_text", this.getNextHighestDepth (), 10, 10, 300, 100);
title_text. Multiline = false;
title_text.WordWrap = false;
title_text. Text = title;
title_text.setTextFormat (title_fmt);
I tried to do inside loops using the number of the loop under the title of the textfield object when it was created, but then I can't find a way to reference and assign the .text.
Any help would be great, or if there is a different command to use that would work better than createTextField, I'm still pretty new flash and actionscript.
Thanks in advance.You can always just use a datagrid for this. It adds to the size of your file, but it also looks good, scrolls AND is sortable and resizable accepts arrays as dataproviders. That being said, you can reference your clip as follows:
-
can I insert a column of table in mysql?
Hello
I have a long column of table of numbers. I use labsql to connect to mysql.
When I was a number, I change my channel number and then concatenate it with commands insert to insert my mysql table number.
now, I want to insert a long column of numbers to mysql, but it is difficult. because for there needs to like before.
can I insert this table in the form of lots and without recourse to a 'for' and as fast as possible?
Best regards
-
No data found error in the loop of the nested table
Hi team,
I'm working on the example to get data in a nested loop using table, but didn't get the no data below found error
DECLARE
Is of TYPE numlist array of integer;
list1 numlist: = numlist (11,22,33,44);
BEGIN
List1.Delete (2);
DBMS_OUTPUT. Put_line ("is the last element" |) List1.last | | "total elementis' | List1.Count);
List1.extend (4.3);
BECAUSE me in list1.first... List1.last loop - get ANY DATA FOUND error in this line
DBMS_OUTPUT. Put_line ('Values' | list1 (i));
end loop;
END;Could you please help me where I am wrong.
Thank you very much.
You get this error because the element 2 has been removed and in the loop, you are iterating over all the elements from 1 to 3.
To avoid this, use the type of loop below:
l_index: = names_in. FIRST;
While (l_index IS NOT NULL)
LOOP
DBMS_OUTPUT. PUT_LINE
(names_in (l_index));
l_index: = names_in. NEXT
(l_index);
END LOOP;
Maybe you are looking for
-
XP with new HP209 - installed printer system. Look at a process through the Task Manager, I can watch spoolsv.exe slowly consume all the memory. This happens without any printing activity. Tried to uninstall and then reinstall the printer, but has
-
I have a HP DeskJet 1050 printer. It gives me 5 print options:1 paper, fast draft quality2 paper, normal quality3. paper, best quality.. .and 2 more for the specialty paper and photo paper.By default, the printer, is set to use the option 'plain pape
-
Convert dates running in date ranges
Good morning/afternoon/evening experts!Oracle - Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit VersionI have data like belowLocation & Date the number of employees in the absence of ViceDEPT_ID DAILY_DATE POSITION ABSENT_EMP-----
-
Impossible to install on the computer Windows 10 CC
I tried several times to download and install CC on my new computer WIndows 10. Firewall and security software has been turned off. The computer is on a wireless network. Get to most of the 201 and occasionally 204 error messages. My internet connect
-
Download cc already have lightroom 5
I am currently using Lightroom 5 and also use elements. When I buy and download creative cloud, what happens to my photos and current catalogues?Shelly Rosenberg