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.





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




View Complete Forum Thread with Replies

Related Forum Messages:
Create A Mysql Query That Will Look In A Table And Come Back With The Most Used Phrase In A Certain Cell In The Table?
How can I create a mysql query that will look in a table and come back with the most used phrase in a certain cell in the table?

4|Truck|Chevy
5|Car|Honda
6|Car|Toyota
7|Van|Chevy
8|Car|Mitsubishi
9|Truck|Toyota

I want a print out from mysql to be like this:

Car 3
Truck 2
Van 1

Is there any way to have it count up how many of each unique things there are in a cell in a table, and have it decending from the first one being the highest number?

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

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

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

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 !
MySQL Table - Limit The Size Of A Table
Is there a way (either through SQL or PHP) to limit the size of a table. So, for example, I can make sure that a table can't contain more than 100 sets of data?

View Replies !
Find All Of The Rows In The Primary Table That Doesn't Exist In The Foreign Table
i have 2 databases, one uses the primary key of another as the foreign key. I want to find all of the rows in the primary table that doesn't exist in the foreign table. e.g:

table jobs:

job_id
company_id
job_name
job_text
date
...

table companies
company_id
company_name
...

from the example above i want to find all companies that have NOT had any jobs between one date and another.

View Replies !
Integrate A VBulletin Board User Table With Another Software Projects Table.
I'm trying to figure a simple query out but for some reason I can't think of how to do it? It's been a while since I've played with the two and I couldn't even find anything on Google either. What I'm trying to accomplish is fairly simple. I'm trying to Integrate a vBulletin board user table with another software projects Table.

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 !
Create A Table Say 3 Rows 3 Cols And Put An Include In Each Table Cell
I have been playing with php includes and thought it would be interesting to create a table say 3 rows 3 cols and put an include in each table cell pointing to other sites, i thought make each cell 500px wide and i would have a page with say four news sites from different countries, so i built my table added this in
<?php include("http://www.cnn.com")?>

plus others uploaded it then sat back to watch my master peice in action, but hey guess what! includes dont quite work like that, the sites all loaded under each other and the page was veery wide, and even my nav table include had the same rollover effect as the first site in the includes.

Is there a way this can be done easily or should i forget this idea now, I have no need for this on my site I am just at the start of learning php so have tried this just for education reasons.

View Replies !
Drop Down A Table Is Suppose To Show Up To Give You The Geocache Table
Under the drop down a table is suppose to show up to give you the geocache table when I had the drop down setup as html it worked fine which leads me to believe something is conflicting in my code. I need an extra pair of eyes to look at it, cause I just cant catch what Im missing. PHP Code:

<?php
//include files to configure db and open it
include 'config.php'
include 'opendb.php'
//pull name for drop down
$query  = "SELECT name FROM geocache";
$result = mysql_query($query);
$options = "";
// find the selected geo name
$result2 = mysql_query("SELECT * FROM geocache WHERE name = '" . $_POST['name'] . "'");
?>
........

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

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

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

View Replies !
Displaying Data From One Table But Ordering By Info From Another Table
I have two tables. One table (we'll call it 'table1') is set up like this:

email address userinfo
email@email1.com userdata1
email@email3.com userdata3
email@email2.com userdata2
etc... etc...

In the above table, the email addresses are in no particular order cause the row is created when someone adds their userinfo. Code:

View Replies !
How Create A Temp Table As A Copy Of A Existing Table?
how create a temp table as a copy of a existing table and then update1 field and insert the hole temp table back in the existing table? .....

View Replies !
Showing Data From A Table Based On Infos From Another Table!
i have 2 tables in my database : THREAD, and POST

THREAD's rows are: THREADID, TITLE + FORUMID + REPLYCOUNT + VIEWS
POST's rows are: THREADID, PAGETEXT and PARENTID

i'm a big php newbie... I want to display the LAST TWO messages (highest THREADID) of my forum number 99 (FORUMID=99).

I can probably do that, but the problem is that the text of the message is located in another table.. and it's getting too hard for my low-skilled brain lol

so basically I would like to check in "THREAD" for the highest THREADID where FORUMID=99, display the TITLE, REPLYCOUNT and VIEWS, and then check in POST for the same two THREADID's where PARENTID=0 (meaning it is the first message in the thread) and finally display the PAGETEXT !

Could anyone give me a PHP code that would display that?

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 !
Search Results From Table And Relational Table
I have a products table with product name, supplier, size, price etc. and a category table with assigned products. Products can belong to multiple categories so the relationship is one to many. I want to search the products by category, supplier, size and minimum & maximum price. My current sql looks like this: PHP Code:

SELECT cats.*, products.*,
FROM cats, products
WHERE cats.catid LIKE '$_GET[catid]'
AND products.price BETWEEN '$_GET[minprice]' AND  '$_GET[maxprice]'
AND products.supplier LIKE '$_GET[supplier]'
AND products.size LIKE '$_GET[size]'

this returns the correct results from the main products table search parameters but doesn't return the correct category. I saw some postings about UNION but I don't understand it and am not even sure if it's what I need.

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 !
Getting Sum Of Table Cell Values From A Large Table
I have a MySQL table that contains data from a survey. The survey has about 30 questions and hence at least 30 fields in the table. All the questions are multiple choice and have 5 to 10 possible answers.

Now, to generate a report that contains totals of each item (for example if a question "favorite sport" has 10 possible answers, S1, S2,...,S10, I need to know how many people answered S1 as their favorite sport, how many answered S2, and so on. And this I need to do for each field for any given date range. Code:

View Replies !
Preg_replace - <table> -> [table] And </table> -> [/table]
I have to ask you about preg_replace:
i need to change <table> -> [table] and </table> -> [/table]
can i make it both in a one expression?

View Replies !
Create A Multi Table Database In MySQL And Write To And Retrieve Information Using MySQL.
I am trying to create a multi table database in MySQL and write to and retrieve information using MySQL. I am able to insert and call data easily enough going into one table, but I am having problems with connecting tables and using the idea of normalization.

I am starting simple with an online registration for alumni of an association. My first table in a database is called alumni and it stores there e-mail address, first and last name and year of graduation. Code:

View Replies !
Match Whats Between <TABLE And </TABLE>
Very simple regex, but just can't get it to work:

I'm trying to match whats between <TABLE and </TABLE>

this is the code I'm using:

if(preg_match_all("/<TABLE(.*)</TABLE>/i", $page, $matches))
{

$num_matches = count($matches[0]);

for($i=0; $i<$num_matches; $i++)
{

$this_match = $matches[1][$i];

echo $this_match . "<br>
";

}
}

Any ideas???

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

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

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

View Replies !
Referencing Table 2 With Info From Table 1
Going further than expected with my db. I have 2 tables:

table 1 has 'id', 'region', 'regionid', and 'locationid'

table 2 has matching 'id', 'address', city, state, zip.

i am trying to use my 'region' and 'regionid' to get my multiple 'id' selections from table 1 to reference all the info in table 2 and display.

View Replies !
Creating A New Table With A Variable Table Name
Is there a way to automatically create a table with a tablename that is taken from a field the user has previously entered (i.e. username). I have tried :

$sql ='CREATE TABLE $username (....)' and
$sql ='CREATE TABLE '$username' (....)'

but neither work. Any ideas??

View Replies !
Move Data From One Table To Another Table
I am learning PHP and MySQL so i want to create a simple submit form. Suppose there are 3 test boxes how do i insert the data entered in the text boxes in to the mysql table when the user hits the submit button. Also in PHP how can i "move" data from one table to another table.

View Replies !
HTML Table From Database Table
I need an html table that outputs all the events in my database table and shows their id number, title, and timestamp. What would be the easiest way to do this? I was thinking something like: Code:

View Replies !
From CSV To MySQL Table
I've a CSV file with 3 columns

ID - Price1 - Price2

How I would like to update the records of a MySQL tables that has the
same ID of the CSV files.

How Can I do this? Read from CSV and update MySQL table?

View Replies !
A MySQL Table
I'm trying to read all the data in a table and I'm using the code:

$query = "select name, xpos, ypos from playervars";
$result = mysqli_query($cxn, $query)
   or die("Could not execute query.");
$row = mysqli_fetch_assoc($result);
print_r ($row);

And all it returns is the first line of the table. I want to select it all. Is this possible?

View Replies !
Mysql Table
I dont know to much about php and mysql, but is their a way to check if theirs something in a secific colum and if so then do one thing if not then do something else? like

if(check=true)
echo 'it existsed'
else
echo 'it didnt exist'

View Replies !
MySQL Table(s)
I want to be able to keep track of activities along with companies. So (I think) I need to have 2 MySQL tables. Code:

View Replies !
Table Via Mysql
I have this:

$mysql_link = mysql_connect($hostname, $username, $password);
mysql_select_db($databasename);
$create = "CREATE TABLE 'photosgigs' ('id' INT(4) NOT NULL AUTO_INCREMENT,
'table_gal' VARCHAR(100) NOT NULL, 'gallery' VARCHAR(100) NOT NULL, PRIMARY
KEY ('id'))";
mysql_query($create,$mysql_link) or die(failed);

with $hostname, $username & $password set.

Kathryn (Fire Juggler)
http://www.firejugglers.34sp.com
http://www.cornwalljugglers.co.uk

View Replies !
Mysql Table And Use
i can retrieve an id from a table in mysql and use it in a hidden field in my form so that what ever gets posted in that form can be linked to the item with the id in another table am doing a forum and i want to link topics with replies.

View Replies !
Exporting MySQL Table
Hi,

How do you export a MySQL table to a tab-delimited text file so I can put it into excel?

View Replies !
Select From A Mysql Table
I want to pull one field from a mysql table. How do I do that? Do I use SELECT? The field name is $sip_visitornum. And I want the last value that was inputted in to the db. I already have the code to get the visitor number but I don't know how to display data from the database properly. Thanks.

View Replies !
How To Create A MySQL Table With PHP?
How to create a MySQL table with PHP?

View Replies !
Getting Mysql Table Info?
Suppose I have a table with name 'tablename' in my database.

If I have no idea what are the contents of this table, is it still possible to retrieve the structural info in this table, like the field names and sizes?

View Replies !
Get Max Value In MySQL Table Field
I have a 2-field table "pageref".

The fields are: "pagerefno" - which is index and primary key, and "url".

I need to find the max value in "pagerefno", so wrote the following code:

$query ="SELECT max(pagerefno) FROM pageref";
$result = mysql_query($query) or die ("Error in query: $query. " .
mysql_error());
$row = mysql_fetch_row($result);
echo row[0];

But this results in a blank screen. I'd be grateful for a steer, here.

View Replies !
Search A MySQL Table
I want to create a php script to search a mySQL table. I started to create the script myself, but I got stuck, because the script became VERY complex. The reason why it's complex is this:

*the script must be able to search all four columns of the table.
if the user defines four different values to search (one for each type of variable (ie.: for each column)). If he doesn't give four values but by example only two, the script needs to search on these two values...

*the script needs to return all four values of all the rows that match the query

*the script may not return each result more than one time

*if possible, the script needs to return 'the best match' on top

examples:
consider a table with four columns:
animal_type |age | name | sex
horse | 5 |beauty| female
horse | 4 |bless |male
cat | 9 |***** |female

the query (horse,5,beauty,female) must return
horse | 5 |beauty| female (only one time!!! this sounds logic, but it isn't!!!)

the query(female) must return
horse | 5 |beauty| female
cat | 9 |***** |female

the query (horse, female) must return
1) horse | 5 |beauty| female
2) horse | 4 |bless |male
3) cat | 9 |***** |female
(number 1 must be on top; 2 and 3 may be changed of place, because they only match one variable!!)

View Replies !
Creating Mysql Table
I have PHP script that creates a mysql table. My problem is when I goto the following php page to access the table it says "missing table 'table name'" I look in phpmyadmin and its clearly there. Eventually after refreshing the page like ten times it detects and works. Do I have to reconnect the mysql connection or something?

View Replies !
PHP MySQL Updating Table Row
I have a small database of books that a client can add, search and edit (hopefully) books; all online (something very simple). So far I've been successful in creating the adding of books and searching and retrieving the info in fields to edit; but I haven't been able to execute the edits. Here's the script I have to retrieve the database info and place them in the fields to edit (I didn't copy all the mysql connection script, it works fine): PHP Code:

View Replies !
How To Get A Field In The Last Row Of Mysql Table.
There is a certain field that I wish to get in the last row (it will always be in the last row, even if I add to the table) of my mysql table. How do I output this? I assumed that I would be using a LIMIT command and a DESCRIBE command, however I looked at mysql.com and couldn't find anything .

View Replies !
Table Dump With MySQL
I have recently moved from a host that provided only 1 mySQL db, to a host that allows multiple db's. How do I dump a table, or tables from the single db...into a new db(s)?
I've used this before (to dump the entire db):

mysqldump -h mysite.com -q mysite_dbname > db_dump.sql -pmysitepassword

but I want to extract specific table(s) from the origian db and move them into newly created db's of their own on the new server.

View Replies !
Mysql Empty Table
does anyone know what the mysql comand to empty and table?

View Replies !
MySQL Table Create
Here is the code I'm trying to create the database with (I'm using phpMyAdmin so I just select the file I want to use and press submit and it creates the tables).

CREATE TABLE bips (
banned_ip varchar(15) NOT NULL);

CREATE TABLE messages (
entry_id double(16,4) DEFAULT &#390;.0000' NOT NULL auto_increment,
name varchar(25) NOT NULL,
email varchar(35) NOT NULL,
icq int(11) NOT NULL,
http varchar(50) NOT NULL,
message mediumtext NOT NULL,
when int(12) NOT NULL,
ip varchar(15) NOT NULL,
UNIQUE entry_id (entry_id),
PRIMARY KEY (entry_id));

------------------------
phpMyAdmin gives me an error with that, (none of those tables exists btw)... the error is

MySQL said: You have an error in your SQL syntax near 'when int(12) NOT NULL, ip varchar(15) NOT NULL, UNIQUE entry_id (entry_i' at line 8 .

View Replies !
Getting Mysql Table Size?
How would I go about getting the size of a table in a mysql database with php? I am unable to find info on this in the manual. Which page is it on?

View Replies !
Mysql Table - Add It, If It Does Not Already Exist
If I write an update script, so people can upgrade their software to
the newest version I've written, and since the last version I've
created a new table in the database, so I want to add it, if it does
not already exist, is the syntax something like

create table if not exists subscribers

View Replies !

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