Jump to content

help with select statment


knowram

Recommended Posts

is there a what to do some thing like this

 

$result = mysql_query("select * from Networkinfo where mNum 'is the highest' ") or
				die ("nope1");

 

I am trying to figure out a way to assign an increasing number to each entry that gets added to a table. So my thinking is that i have to know the highest number that is currently in the table and then just add 1. or is there another way?

 

Thanks for the help

Link to comment
https://forums.phpfreaks.com/topic/56760-help-with-select-statment/
Share on other sites

the first table only has 2 fields

right now they are set up like this

 

mNum            varchar(255)

mCompany      varchar(255)

 

i am using phpmyadmin however I am really new to it. I don't know much more then adding adding fields to tables and tables to databases and adding databases. I have been mostly using either varchar or me mediumtext for the field types. And i know nothing about keys yet. however I am a fast learner

ok now that i have done that let me explain what i am trying to do. I have to tables

 

table 1 (aMember)

 

mNum

mCompany

 

table 2 (aOffice)

 

mNum

oNum

Office

Address

Domain

Net_Connection

 

I have several member company's (mCompany) and each of those has several Offices. if I add a new office to a member company i just add the info to the aOffice table using putting the mNum from the member company entry in the aMember table. no big deal.

 

But if I am adding a new Office that is part of a new member company I want to add the member company name to the aMember table which is now getting a mNum assigned automatically. How do I know what that mNum is so I can use it when adding the office info to the aOffice table?

 

Hope that makes sense.

thats fine, i generally just make a field called ID as my primary key and auto increment it for any table just for ease of use.  Then i link between tables with my users names.

 

try the function $idnum=mysql_insert_id();

where it will give you the autokey num of the last query of insertion

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.