SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: Database extraction by row
-
Jul 17, 2006, 22:31 #1
- Join Date
- Apr 2006
- Location
- Timisoara/Romania
- Posts
- 45
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Database extraction by row
Hello,
I can't get this trought.
My link will be:
http://localhost/blabla/file.php?action=5
If action = 5 then the 5 ROW from a table in the database will show.
If action = 88 then the 88 ROW from a table will show.
Got my point?
I know how to show the info, I just don't know how to privatly show only ONE row. the action = number should be my ID witch is auto_increment.
I also do that with SWITCH.
-
Jul 17, 2006, 22:37 #2
- Join Date
- Nov 2004
- Location
- London
- Posts
- 248
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The query should be something like:
$sql= "select * from table_name where id=" . $_GET['action'];
Not sure what you mean by "I just don't know how to privatly show only ONE row"... so post back if this isn't what you're looking for
-
Jul 17, 2006, 22:42 #3
- Join Date
- Apr 2006
- Location
- Timisoara/Romania
- Posts
- 45
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:$query = "SELECT * FROM `problems` ORDER BY `prob_id`"; $result = mysql_query($query); $num_results = mysql_num_rows($result); $row = mysql_fetch_array($result); if(!isset($_GET['actiune'])) $_GET['actiune'] = ''; $id = $row['prob_id']; switch ($_GET['actiune']){ case $id: ?> <table class="tabel_list" cellspacing="0"> <tr> <td colspan="2" class="tabel_login_header">PROBLEM VIEW </td> </tr> <tr> <td><?= $row['prob_id'] ?></td> <td><?= $row['name'] ?></td> </tr> <tr> <td>ADRESA</td> <td><?= $row['address'] ?></td> </tr> <tr> <td>DESCRIERE</td> <td><?= $row['description'] ?></td>
So normaly I get the page showed, but ONLY with the first entry (the first row from the database). I want the "CASE" to be the ROW ID, si if page.php?actiune=5 I want the 5 row from the table to be showed.
-
Jul 17, 2006, 22:48 #4
- Join Date
- Apr 2006
- Location
- Timisoara/Romania
- Posts
- 45
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
What's wrong here:
$query = "SELECT * FROM `problems` WHERE prob_id='. $_GET['actiune'] .' ORDER BY `prob_id`";
-
Jul 17, 2006, 22:55 #5
- Join Date
- Nov 2004
- Location
- London
- Posts
- 248
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Because you're specifying the ID - and therefore returnng just one row - there's no need for the ORDER BY clause.
Also, the single quotes in the GET are messing things up. Try this:
$query = "SELECT * FROM `problems` WHERE prob_id=" . $_GET['actiune'];
-
Jul 17, 2006, 22:58 #6
- Join Date
- Apr 2006
- Location
- Timisoara/Romania
- Posts
- 45
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
ok. i'v done it. Thanks.
-
Jul 17, 2006, 23:02 #7
- Join Date
- Nov 2004
- Location
- London
- Posts
- 248
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Excellent!
Bookmarks