TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   getting results from database but diverent (http://www.talkphp.com/absolute-beginners/2555-getting-results-database-but-diverent.html)

Face_Of_Boe 03-30-2008 05:43 PM

getting results from database but diverent
 
Hey everyone im new here my mother allways told me its nice to intreduce yourself first..

So here i go my name is marco my hobbys are webdesing.
I'm learn greedy and i'm 22 years old.
Annyway Tht must be enouf hehe moving on to my qeustion

I have the following problem I'm trying to get a surtain part of my database to display in my website
But the only thing i seem to get is a tabel and i dont want a table i just want the information to be displayed where i wanted.
(sorry if it sounds fage)
To make it more clear I'll just link you to a site tht has it like i want 24 Episode Guide - 24 Season Episodes - TV.com
please help me anny more info needed ill add on question im just new to it so please forgive me if i do something wrong.
sinds im ferry ferry new to php ive been going crazy by browsing true i think more then a hundred tutorials without anny sucsess

Please help me

Thx in advanced,
Marco

flyingbuddha 03-31-2008 04:48 PM

Hi Marco,

Perhaps you could post a sample of your code so we can see how far you've got so far, then we can help you fill the holes :)

Face_Of_Boe 04-01-2008 06:47 AM

Sorry not ferry smart of me not to include that.

The problem with this script is when i have two records in my db for acsample:
test the name & test the name2
it displays both of them in stead of just one, and i have no clue how to make it work around this.

PHP Code:

<?php
include ("connect.php");

mysql_select_db("test_db"$con);

$result mysql_query("SELECT * FROM test");

while(
$row mysql_fetch_array($result))
  {
  echo 
"<td>" $row['name'] . "</td>";
  }
mysql_close($con);

?>

------edit--------
sorry for the <td> tags forgot to edit em out
------edit--------

marxx 04-01-2008 10:07 AM

Well if you have to get just one of them then try this.
PHP Code:

<?php
include ("connect.php");

mysql_select_db("test_db"$con);

$result mysql_query("SELECT * FROM test");
$res mysql_fetch_array($result);

print(
"<td> " $res['test the name'] . " </td>");

mysql_close($con);

?>


abiko 04-01-2008 12:21 PM

You can always use the WHERE in your SQL. Of course you will have to know the id or any other "connection" you can make to get that item out.

Your query would look like then
PHP Code:

<?php
include ("connect.php");

mysql_select_db("test_db"$con);

// The ID part
// Lets say you have index.php?id=12
$id $_GET['id'];
if ( 
is_numeric$id ) ) {
$result mysql_query("SELECT * FROM test WHERE id = '".$id."'");

while ( 
$res mysql_fetch_array($result) ) {
 echo 
"<td> " $res['test_the_name'] . " </td>";
}


print(
"<td> " $res['test the name'] . " </td>");

mysql_close($con);
} else {
 die( 
"Error");
}

?>

I'm just guessing here, can you post your db table structure?
:-/

Face_Of_Boe 01-06-2009 12:02 PM

Thank you for your reply's this didt solve my problem thank you :D sorry it took so long for me to reply but i had some acc problems :)


All times are GMT. The time now is 11:27 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0