Jump to content

beginner mysql query with php help


knowram

Recommended Posts

I am not sure if this question belongs in the mysql section or not so if it does forgive me.

 

Say I have the following table:

PID Action Hardware Set Dialplan

14 I         test-HS-2 test2

14 I         test-HS-1         TestDialpl

14 I         test-HS-2 test3

 

I would like to select the second time PID = 14.

 

 

Link to comment
Share on other sites

So I know I can do the following. Say the Table name is Tabs

$Tab = mysql_query("SELECT * from `Tabs` WHERE PID = '14'");

$Tab = mysql_fetch_array($Tab, MYSQL_ASSOC);

 

And it will return first row in the table where PID = 14

or

$result = mysql_query("select * from `Tabs` where  PID = '14' ") or
						die ("nope");

while ($Tab = mysql_fetch_array($result, MYSQL_ASSOC)){
print_r($Tab);
}

and that will print all rows where PID = 14.

 

What I am trying to do is just get the content of the second row where PID = 14.

Link to comment
Share on other sites

if i understand, you need this line

 

14  I            test-HS-1          TestDialpl

 

You might want to try

 

$Tab = mysql_query("SELECT * from `Tabs` WHERE PID = '14' AND hardware = ' test-HS-1'");

 

But this is not a good approach. You need a unique ID in your table.. Like

 

+---++---++-------++------------+

| ID | PID| |action|  |Hardware|

+---++---++-------++------------+

|  1 | 14  |

|  2 | 14  |

|  3 | 14  |

|  4 | 14  |

 

And so on

 

Then $Tab = mysql_query("SELECT * from `Tabs` WHERE ID = '2'");

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.