473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

select single row by id in php mysql

Hi there, I am learning php mysql. Now I am trying to shwo a single row from a table by inserting id. That means i can read any row form table by inserting only id and that id contains other information like name , address will show with id. Please help....Thanks in advance.
Nov 30 '11 #1
2 11659
canabatz
155 100+
Expand|Select|Wrap|Line Numbers
  1. $sql=mysql_query("select * from `yourtable` where id='theid'")or die(mysql_error());
  2. $row=mysql_fetch_assoc($sql);
  3. echo $row['name1'].$row['name2'].$row['name3'].$row['name4'];
  4.  
hope it helps
Dec 1 '11 #2
omerbutt
638 512MB
$sql=mysql_query("select * from `yourtable` where id='theid'")or die(mysql_error());
$row=mysql_fetch_assoc($sql);
echo $row['name1'].$row['name2'].$row['name3'].$row['name4'];
you need to add limit 1 to ensure only 1 reccord is selected as there could be multiple rows against a single id
Expand|Select|Wrap|Line Numbers
  1. $sql=mysql_query("select * from `yourtable` where id='theid' LIMIT 1")or die(mysql_error());
  2.     $row=mysql_fetch_assoc($sql);
  3.     echo $row['name1'].$row['name2'].$row['name3'].$row['name4'];
  4.  
Dec 1 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: kaptain kernel | last post by:
How does one retrieve the rows in a select statement that DONT match the select. select CarIndex FROM DealerCatalog, BigCatalog WHERE DealerCatalog.CarIndex=BigCatalog.CarIndex finds all the...
3
by: R.G. Vervoort | last post by:
I would like to select an option in a pulldown, select a record in a mysql database depending on the pulldown selection and then put the data from the record in the textfields. I can retrieve...
0
by: Rupak Banerjee | last post by:
Hi, I have a mysql database running on Mysql version 3.23.53 on a Red Hat Linux 7.2. In the database there is a single table with over 150,000 records. Unfortunately, the performance of that table...
1
by: pizzy | last post by:
Problem: I am trying to develope my personal site to select from my mysql database and organize data on the page so that it will display all the submissions for that day, then break and display...
1
by: PCK | last post by:
I am trying to select a single cell from an Excel workbook. I am using the following code. strCN = GetExcelConnection("C:\Test\Excel.xls") strCMD = "select * from " oleDbCN = New...
3
by: veg_all | last post by:
Is there a way to select a single column from a mysql database and directly put the results into an arrray? Here is the workaround below, but I would like to elimniate the array_push step: ...
0
by: ZoombyWoof | last post by:
Hi. I have ran into a weird thing I just can't find any solution for. I have googled and searched but no luck. The problem is that when I select TIME values from MySQL from python, I get wrong...
9
by: newbie | last post by:
I am writing a DB like this: --------------------------------------------------------------------- | id (auto_incremented filed) | foo | bar |...
2
by: newbie | last post by:
Dear folks, pardon me if this is a stupid question. For this table --------------------------------------- | id | foo | bar | -------------------------------------- I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.