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




How Can I Find A Name From One Table In A Text From Another Table?


I have one table with a description field and other info, and I also have another table with a list of names and picture url:s. When I display the text description on my site I'd like to know if there are a match with a name from the 'names' table in the text. Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How Do You Find Out How Many Rows Are In A Table?
How can you tell(using php) how many rows are in a database table.

Find Match In MySQL Table
I have a table with several fields (id, company, city, and others). What I think I want to do is to select all the records (ordering by company asc for display purposes) and loop through them to find the requested id, BUT then I need to know the current row that match occurs in the overall list.

If I am not mistaken, if I do the match on the 'id' in the table with the id requested, then only that one row will be selected. So then for getting the prev/next links to work off the 'ordered by company asc' order and not just the 'id' sort, I need to know where this particular id matched row is in the overall list.

REQ How Would I Compare Multiple Date Fields In One Table To Find The Latest Entry Opps
i didn't explain it correctly before
my table is like this

example fields:
ID name username outcome date1 date2 date3 (etc..) - date15 price1 price2 price3 (etc..)

I know that Mysql query order by will compare records on a specific date, but how do i compare
multiple fields within the same record. Want to find the latest date within the record..

Grab Content From HTML Table And Place Into MySQL Table?
I am in the process of helping a co-worker upgrade some of his old static html pages into dynamic MySQL driven pages. He currently has a lot of pages with huge tables displaying data. Does anyone know if there is a script or class that can convert a table to a .sql file for upload?

Table Background Color Based On Results From MySQL Table
I am trying to get the "Did User Agree" field on a database query to be colored Green for "Agreed" Red for "Disagreed" and Blue for "Agreed (2nd Time)" .. I have my PHP setup to do the query just fine as of right now with alternating column colors, just can't seem to get the colors to work as I am hoping for.  Can anyone help me get the Agreed? table's background color to the colors above? Code:

Create A Table Regarding A Text File
I have this .txt file :

Roger|tow25$rank259
Isabelle|tow36$rank24
Pascal|tow12$rank29
Sergeď|tow45$rank5
Michel|tow1245$rank45478
Frédéric|tow1$rank125425

And this programm php3
<?php
$fichier = "classeur.txt";
if($fp = fopen($fichier,"r")){
$ligne=1;
echo "<table border=1 bordercolor="#00CCFF" width=500>
";
echo "<tr align=center><td colspan=3>TITRE</td>";
while (!feof($fp)) {
list( $name, $tampon ) = explode( "|tow", $fp );
list( $tow, $obj ) = explode ( "$rank", $tampon );
echo " <tr>";
echo "<td
align=center><b>Nom".$name."</b></td><td>Tow".$tow."</td><td>Obj".$obj."</td[color=blue]
>";[/color]
echo "</tr>
";
$ligne++;
echo "</table>
";
echo "$cell";
fclose($fp);
}else{
echo "Error : open impossible ".$fichier;
exit();
}
?>

I would like to past each value of the lines in the tex file, in 3 variables
$nom; $tow; $obj
and create a table with 3 column ( column 1 the name, in 2 the tow, and in 3
the obj)

Populating Table With Text File
My web hosting service uses phpMyAdmin and at the bottom of the screen
iis an area where I can upload a text file to populate a table.

I have a table named groups with two fields:
groups_idauto-increment primary
groups_name

So how do I create my text file to populate this table?

I'm going to use MS Notepad.

If it's set to auto-increment, do I need to include the number? If
so, does it start at 0 (zero)?

Would the file look like:

0,students
1,faculty
2, staff

or just

students
faculty
staff



Outputting A Table Or Form Using SHOW FIELDS FROM Table
In the code the MySQL database was queried using "SHOW FIELDS FROM table" which and the returned results of column names was then use to build an output for a form and a table with php using a series of if statements along the lines of if the returned field name matches something echo a text input field.

I have never seen this done this way before, so I want to get the opinion of the devshed user. Does it seem like an unsual long process to build up a form. Is there a security advantage doing it this way? Has anyone ever done it this way before?

Finding Matches In A Table And Then Moving That Match To Another Table?
Ok, I have a database that has a table called critiera in this table
is to fields on is ID and the other is critiera.

Now I want to filter out all the one that don't apple to the list and
move the one that match to a different database.

I know how to open a connection, close, select

but I don't know how I would inside of a database use another one as
the way to create the list of critieras....

Mysql Fetch_field Gets Table Alias, Not Real Table Name
After a SQL 'select .... from tablename alias'
the mysql_fetch_field function returns a value $result=>table which
will contain the alias, not the actual table name.
Is there a way to get the actual table name ?

I am running mysql 4.1 and php 4.4

Grab Data From A Table, Echo, Then Insert It Into A New Table...
I'm trying to do is count the number of times usernames shows up in a table. I then want to reinsert that information into a different table with the Username in column1 & the occurrences in column2 for every user that is echoed on the page. Code:

Using PHP To Sort Data In MySQL Table 1 By Values In Table 2
I have a MySQL database with 2 tables in it. products and prices.. Products has a field in it called 'prodno'. Prices has a field in it called 'prodid'.

There is one of each item in products and each product has it's own unique 'prodno'

There are multiple instances of each product's pricing in prices.. One for each price.. So if a product had multiple prices depending on quantity it would have an entry for each price.. Example:

id = 1
prodid = 7001
qty = 300
price = 12.5

id = 2
prodid = 7001
qty = 400
price = 15.5

I was wondering if I could query the database getting info from the products table but sort it according to the prices in the prices table.

Kinda like doing a "SELECT * FROM products" ordering it by the lowest price value from each item..

This is all very confusing to me, and I'm the one writing it. Let's try one last time..

Query the database selecting * from products (I plan on using all the info in products) and ordering them by the lowest price for each item in the prices table. I've tried sorting the results of just a basic SELECT * FROM products using Javascript and PHP but with pagination in the results it makes it a bit hard.

How To Make Text Wrap In Table Cells?
I don't understand this at all. I have a table with fixed width and height in pixels. Yet when I place a long text string in a cell, the cell expands as far as needed to the right or left to fit the string on one line. This is driving me quite mad. How do I ensure that a long string is displayed in a neat, orderly fashion? My question has nothing to go with wrapping text around images. I just simply need to have text wrapped!

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]

Problem In Handling Long Text In MYSQL Table
i am making a database driven website which is working fine.
My web page contains lot of text and it is very diffcult to upadate its content from the text_field of MQSQL table. As i have to read each line again and again to update it.

I have alloted parent_id to each category_id in my database table and thus retreving results from it...

I want to know what should i do to handle this long text ...such as if i am able to make a seperate text file for each of my html_body variable and somehow include that file to a webpage when i select a particular parent_id from my wepage.

Using Php To Move Rows From Text File Into Mysql Table
Can anyone point me in the right direction for the way to read a text file a
line at a time and separate the fields on that line and use them as data in
an INSERT to add a record to a mysql table. Then read the second line in
text file and repeat.

How To Populate HTML Table From Local Text File.
I am looking for a way to populate an HTML table from an external
local text file which looks like this:

DATE/TIME LAT. LON. DEPTH. ML.
-------------------- ---------- ---------- ------- -------
21/03/2005-04:06:03 XX,XX XX,XX 171 3,42
21/03/2005-12:23:53 XX,XX XX,XX 500 5,4
21/03/2005-12:43:10 XX,XX XX,XX 553 5,38
21/03/2005-18:47:51 XX,XX XX,XX 162 3,91
21/03/2005-19:29:49 XX,XX XX,XX 500 3,51
21/03/2005-20:04:51 XX,XX X,X 75 3,72

The file could have more rows (DATA) that I show here. The file is
provided to me on a daily basis and I have to update a web page daily
with the contents of the file.

I considered using JavaScript embedded in the HTML page but I am a
newbie on what scripting for the web it refers.

How can I populate the HTML table with this text file which changes
everyday.

Also, is it possible to use php client-side only, without a server?

Explode Text Area Into Array For MySQL Table
On my site, I have a textarea where users enter their sites' information in the following format (tab-delimited):

Site Name <tab> Site Description <tab> URL <newline>
Site Name <tab> Site Description <tab> URL <newline>
(and so on...)

I know I have to use the "Explode function and a loop to get the data into an array and enter it into a MySQL table. Would anyone have a snippet of code off-hand that could show me how to do this?

Creating Temporary Table From Full-text Query
i'm using a full-text search on my db which works fine, but now i'm working on filtering the results further, like products in range of prices. my logic is to simply SELECT them out of the temporary table, only if it would be created. i don't think i need to paste any code since i think you get the idea.

Select From Drop List To Fill Table Column With Text -- HOW ?
I want viewers to compare state laws on a single subject.

Imagine a three-column table with a drop-down box on the top. A viewer
selects a state from the list, and that state's text fills the column below.
The viewer can select states from the drop down lists above the other two
columns as well. If the viewer selects only one, only one column fills. If
the viewer selects two states, two columns fill. Etc.

I could, if appropriate, have a separate htm page with the text for each
state -- california.htm for example. When the viewer selects California from
the drop down list, the column below would "fill" with California.htm.

Or, I could conceivably use a text or mysql database with two fields for
each record: state_name and law_text -- but it would probably be easier to
use separate htm files, since there will only be about 20 states involved,
and the "database" would never have a large number of records.

The table width would be 100% and each cell would be @33%

My site is designed with FP 2002 and runs on Apache/FreeBSD. I have just had
Apache-ASP installed but I have not yet configured or used the module.

Table Based Order Form That Can Email Text Entered?
I have a custom order form that I collaborated on with a friend who knows php.

The form needs updated and the code we put together is hard for me to read and update. I think the form can be refined or rewritten in a more OOP way and hopefully as sematic as possible.

The Form is for entering ready made frames. The Choices are color and size. Here is what I need to do:

Enter Name, Email, Store Number, Comments Etc.Create a table based form where users can only enter numbers in each text field.Upon completion, agreement, and submission of the order an html email is kicked to our inbox. The table remains as it was on the website due to html and a separate print css file. Code:

How To Transfer A Data With An Id To Another Table From A Table?
how am i going to transfer let say a name identified using the suer id and copy the name to the other table having the same user id>?

Returning Table Name As Well As Fields From That Table
I am returning all fields from news and from regional, however I want to determine where the fields have come from when I ouput the data, therefore I need to return the table name with the fields. Is this possible? Code:

Moving Data From One Table To Another Table
Does anyone know how to move one row from a table in a mysql database to another table using php?

Move Table Row To A New Table
I have a database of some information and it is in a table row by row.

I have a page that displays these in a table row by row, however I want to have a link to the side of each row allowing me to transfer that row to a new table.

How would I do this? I've tried a few ways but that was a random guess and didn't work.

How To Find A Match In A Text Field ?
i am using ereg($rowvalue[0],'humor2')==true to find a match in the text field. how can i find a exact match, ie. the text field contains 'humor,humor2'

so, if using ereg the result will be true for both humor and humor2 but only 1 - humor2 is correct. how do i find an exact match ?

How To List/find Html Tags In Text
What I try to do is to search a text for html tags.

Why. Because I want to use nl2br on the text, but since this command add
br instead of all /n it is not a nice thing to add t.x. a html list inside
the text. Of course it is possible to add the list and remove all space
between li tags, but this is not so readable to the writer.

What I try to do is also to add nl only in the plain text and inside li
and td tags. So in the li case I have to find <ul> and </ul> and <table>..

Find And Replace Text In Preg_match Array
I'm trying to change a font color html code once my preg_match_all reads the file. Now the code only shows up when a winner has been posted for that tour. Otherwise it's not visible. So I want to search the preg results which is $matches, for the "font color=3FFF5E" and replace it with "font color=FFFFFF". If the code is not found, continue what it was doing. Code:

Strpos To Find Xml Tags To Pull Out The Text Data
I'm trying to use strpos to find these xml tags so I can pull out the text data; but the bracket chars won't let the function work. Is there another way to do this?

$php_XML_tag = "<codeFacility>ZNY</codeFacility>";
$pos = strpos($php_XML_tag, '<codeFacility>');
print $pos;

results is $pos == 0

Add To Table With FK
ok the main problem i am having is not the adding of data to a table but the retrieveing of a id from another table.

the error is get is "Invalid query: Duplicate entry for key 2"

this is the code i am using the first part is to get the user id from the table user where the company matches. Then the second part is to add that data to the table:

Take Col From 1 Table, Put In Other Table
I have a: database called 'site'

table called 'user' which contains the columns of 'user_id', 'user_email' and 'user_join' and some other columns.

table called 'list' which contains the columns 'id', 'emailaddress' and 'jointime'.

What i would like to do is the following:

A script that gets the info in the selected columns from the table 'user' and then takes that information to update the table 'list'. However the information in the user_join = unixtime (like 1045004759?) and the info in 'jointime' has to be in date-format (like 2003-04-03 13:21:18?) Is this possible to do at all or do i have to update these tables by hand constantly instead of just running a daily script?

How To Get From Which Table Something Comes From?
I have a rating system but I want to make it universal, my rating system is in a different table than my stuff that is being rated so I want to know how I would do to get the table from which the art or w/e comes from so that i  can enter that in the database.

Get The Table Name
Is there a way to get the table name from a database? I want to display the data from a database with 3 tables ordered by the date field and when the i fetch my result i want to know from wich table i got the data.

Table To File
How do you transfer data from a MySQL table into a file(text or other viewable type), using PHP?

Output Into Table
I'd like to output some query results in a table, each result in it's own column and row. Here's an example --

***********************************
IF ($result){
echo "<center><table><tr><td>";
while ($r = mysql_fetch_array($result)) {
$number = $r["stock_number"];
$description = $r["item_description"];
echo "$number<br></td>";
echo "<td>$description<br>";
}
echo "</td></tr></table>";
} else
{
echo "No data.";
*********************************

Except it doesn't work correctly. What is the proper way to accomplish this?

Getting And Printing Last Id From A Table
I'm trying to get the last id from an orders table and increment it by one so the order_id of the new items in a shopping basket will be assigned the order_id suitable

i.e.

current order id is 5 get that number 5 and increment it by one, so that items have order number 6 assigned to them.

Im using this code so far...

Highest Value In Table
I have a table in a MySQL database with two columns: keyword and bid.

How do I find the highest value for "bid" only for a given "keyword"?

For example, if the keyword I was looking for was "PHP", I want to scan all instances of "PHP" in the column "keyword" and then find the one that has the greatest value for "bid".

Search More Than 1 Table
just a curious question on how you people would go about making a search script that wil search 2 different tables on 1 search word and display all the results on 1 page.

Lock The Table
When I using PHP with MySQL, how can I lock the table?

Select Value In A Table
In my sql table I've a list of colors: white, blue, green.....
table colors:
idcolor, coloname
1, white
2, blue
3, green.....
I've some programs sending colors for some material, but I don't want to use
them, I'd like to use my values:
example:
program gives 'dark blue' then I'd like to select blue in my table and...

Table Archivisation
I have large amount of data stored in a table, most of which isn't used any more. However I cannot just delete it. So I want to create an archive table - no problem in that.

The problem comes when I want to return some record from archive to normal table. I need this record to have the same id, as it had before archivisation. How to do that? Id is auto_increment...

Make Table Appear On Top
i made a php with just a table and included all the material with php include http://www.hbksite.com/index2.php but here is the problem when i got to it the menu appears in the middle is there any way to make it be always on top please help here is the code:

How Many Rows In A Table
I am sure there must be an easy way to determine the number of
rows in a table, but I can't find it.

How To Get The Fields From A Table
Because the fields i make in the table are very subject to change and i want to know them without to have written in the php code. So i want to know all fields names from a table in a mysql database.

How Do I Connect To A Table?
I am try to connect to my table I made in PHP Admin and for some reason I can't connect to it! Is it supposed to be something like: Yourusername_mytable? If you are using a hosting provider? PHP Code:

Table Stretching
I have a display page that displays info from a mysql database and it is a pretty small table and sometimes a user might enter a really long text string with no spaces (i.e. - a location of a file like c:windowssystem32drivers... and so on) How can I make this wrap without exapanding my table so the formatting is all messed up.

ASP.NET & PHP - Php Xml Table Display
I hope that there is someone fluent in both php and asp.net who can help me bridge a gap.

In asp.net it is fairly easy to take a simple xml file and display it as a table [or datagrid], using something like:


void Page_Load()
{
String xmlFilename = @"C:...example.xml";
DataSet newDataSet = new DataSet();
newDataSet.ReadXml(xmlFilename);
DataGrid1.DataSource = newDataSet;
DataGrid1.DataBind();
}

followed by:

<asp:DataGrid id="DataGrid1" runat="server"></asp:DataGrid>

I would like to know how to do this in php.

Can't Delete From Table!
I'm not to familiar to php and sql. I have this assignment to read from database in a table and I HAVE TO be able to push a button causing one costumer to vanish. something to do with id = $id... can anyone help me... and help me fast!

This is my code:

Dynamic Table
I'm working on creating a dynamic table generator. The data is read from a database via mySQL. The table sample is: Code:


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