View Full Version : Show data using ID
queerfm
03-14-2008, 01:58 PM
Hi i have a database called funny the table is called jokes
in there i have a list of jokes all done by ID
i need a way to fetch them like
joke number 1
i would it to show in the address bar something like this
http://www.mywebsite.com/joke.php?ID=1
or
http://www.mywebsite.com/TitleOfJoke
and i need to figger out how to show that joke on the page
Thanks
NXArmada
03-14-2008, 03:42 PM
http://www.php-mysql-tutorial.com/
Has alot of good MySQL and PHP tutorials. I suggest you check them out. If you still have problems post back here.
Remember Google is your friend.
$id = $_GET["id"];
$sql = "SELECT * FROM jokes WHERE id = $id";
Correction to your code...
$sql = "SELECT * FROM jokes WHERE id = $id" limit 0,1";
queerfm
03-15-2008, 05:50 AM
Thank you for the help, however it seems not to be working?
This is my PHP code
<?php
include 'include/config.php';
include 'include/opendb.php';
$id = $_GET["id"];
$sql = "SELECT * FROM podcast WHERE id = $id";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "Name :{$row['ID']} <br>" .
"Subject : {$row['podcastname']} <br>" .
"Message : {$row['xmllink']} <br><br>";
}
include 'include/closedb.php';
?>
queerfm
03-16-2008, 02:15 PM
I found this code but its not working PLZ help
<HTML>
<?php
$db = mysql_connect("localhost", "USERNAME", "PASSWORD");
mysql_select_db("twitoo",$db);
$result = mysql_query("SELECT * FROM podcast WHERE id=$id",$db);
$myrow = mysql_fetch_array($result);
echo "First Name: ".$myrow["firstname"];
echo "<br>Last Name: ".$myrow["lastname"];
echo "<br>Nick Name: ".$myrow["nick"];
echo "<br>Email address: ".$myrow["email"];
echo "<br>Salary: ".$myrow["salary"];
?>
</HTML>
Mod Edit: Took out db username and password. Please do not post this information in future posts.
queerfm
03-16-2008, 02:20 PM
Got It Working
Try this:
<HTML>
<?php
$db = mysql_connect("localhost", "USERNAME", "PASSWORD");
mysql_select_db("twitoo",$db);
$result = mysql_query("SELECT * FROM podcast WHERE id=$id")or die(mysql_error());
$myrow = mysql_fetch_array($result);
echo "First Name: $myrow['firstname']";
echo "<br>Last Name:$myrow['lastname']";
echo "<br>Nick Name: $myrow['nick']";
echo "<br>Email address: $myrow['email']";
echo "<br>Salary: $myrow['salary']";
?>
</HTML>
queerfm
03-16-2008, 02:54 PM
Hey i need some more help Sorry
I have this code that use to fetch the xml file from a URL however now that i have everything in the MySQL i need to make it also have the ?id=1 fuction
<?php
/*
You can use this script to pass-through a playlist from an external server to the players.
Just insert the url to external playlist below and copy this file to your server.
You can use the flashvar "file=external_feed.php" in your HTML feed this script to the player.
*/
// build file headers
header("content-type:text/xml;charset=utf-8");
// refer to file
readfile("http://www.abc.net.au/tv/enoughrope/podcast.xml");
// that's all
exit();
?>
If you can help Thank you so much
I don't get what you want. ożo
queerfm
03-16-2008, 03:36 PM
I would like to replace http://www.abc.net.au/tv/enoughrope/podcast.xml with what every the xml URL is in the MySQL
so it would look like something like this
http://www.mysite.com/xml.php?id=1
<?php
/*
You can use this script to pass-through a playlist from an external server to the players.
Just insert the url to external playlist below and copy this file to your server.
You can use the flashvar "file=external_feed.php" in your HTML feed this script to the player.
*/
// build file headers
header("content-type:text/xml;charset=utf-8");
// refer to file
readfile("{$row['xmlURL']}");
// that's all
exit();
?>
Thanks
Didn't I give you the code above?
$page_id = $_GET['id'];
$query = "SELECT * FROM `table_name` WHERE `id`='{$page_id}'";
$result = mysql_query($query)or die(mysql_error());
$myrow = mysql_fetch_array($result);
echo "First Name: $myrow['firstname']";
echo "<br>Last Name:$myrow['lastname']";
echo "<br>Nick Name: $myrow['nick']";
echo "<br>Email address: $myrow['email']";
echo "<br>Salary: $myrow['salary']";
And then just add your code.
queerfm
03-16-2008, 04:45 PM
I did what you said and i get this
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/isearch/public_html/podcast/player/xml.php on line 11
I tryed echo and it does not work
Lets say i am trying to get BBC news RSS feed i have the URL to it in my MySQL database
I would like away to fetch the rss by ID
I hope that helps.
It has to have this for it to work with my Flash Player
header("content-type:text/xml;charset=utf-8");
readfile("BBC RSS FEED");
Well, did you replace table-name with your table? And also the field?
queerfm
03-17-2008, 03:19 AM
Yes i did all that here is the code
<?php
header("content-type:text/xml;charset=utf-8");
include '../include/config.php';
include '../include/opendb.php';
?>
<?php
$id = $_GET["id"];
$sql = "SELECT * FROM podcast WHERE id = $id";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
readfile("{$row['xmllink']}");
}
exit();
include 'include/closedb.php';
?>
Try this:
<?php
header("content-type:text/xml;charset=utf-8");
include ('../include/config.php');
include ('../include/opendb.php';)
?>
<?php
$id = $_GET["id"];
$sql = "SELECT * FROM `podcast` WHERE `id` = `$id`";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
readfile($row['xmllink']);
}
include ('include/closedb.php');
exit;
?>
Heres what I changed:
I added ( and ) to the includes
Added ` and ` before and after tables/fields[optional]
Took your MYSQL_ASSOC out.
Put exit(); under the last include.
Changed exit() to exit.
The exit; is not a function, this is most like the die function but does not return a string which is why we don't use the (), it also needs to be above the rest of the code or else everything under it(but ?>) won't work.
queerfm
03-18-2008, 11:46 AM
Hi i tryed your code found an error and still have not been able to get it to work...
<?php
header("content-type:text/xml;charset=utf-8");
include ('../include/config.php');
include ('../include/opendb.php');
?>
<?php
$id = $_GET["id"];
$sql = "SELECT * FROM `podcast` WHERE `id` = `$id`";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
readfile($row['xmllink']);
}
include ('../include/closedb.php');
exit;
?>
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.