
php query help - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: php query help (/showthread.php?tid=48458)
php query help by Ezra on 08-03-2005 at 07:49 PM
I'm trying to make a interactive page and made a function to query a string from my database.
code: title_query($id)
however, I want to add it to my database. like this:
code: Database -----> title_query($id)
<-----
------> Output on the website
It's kinda hard to explain , I hope someone understands me and can help me...
I just want to be abled to type in my database: title_query(3) and the ouput on the website should be the result of the title_query(3)
RE: php str_replace help by Veggie on 08-03-2005 at 07:52 PM
hhmm i dont really foolow, what has this got to do with str_replace?
RE: php str_replace help by Ezra on 08-03-2005 at 07:54 PM
AH, right, well... forgot to say, I was trying to work with str_replace to let it work, but I thought maybe someone here knows another way.
RE: php query help by Veggie on 08-03-2005 at 07:56 PM
from the look of that little picture you will need 3 quierys, are you using MYSQL?
RE: php query help by Eljay on 08-03-2005 at 07:57 PM
i dont get why you need to insert it and get it back out again, if youre inserting it you obviously have it in a variable so why not just output it normally?
RE: php query help by Ezra on 08-03-2005 at 07:58 PM
That's not really what I mean, and yes I use MySql.
I'll try to explain better 
In my database I type title_query(3), in my code I query the info from the database to the page, but before it ouputs the data to the website I want title_query($id) to be executed.
EDIT: quote: Originally posted by Lee Jeffery
i dont get why you need to insert it and get it back out again, if youre inserting it you obviously have it in a variable so why not just output it normally?
Because all the data is in the database, and for every id I need a different query, like title_query(3) or title_query(4)
RE: php query help by Veggie on 08-03-2005 at 07:59 PM
quote: Originally posted by Ezra
That's not really what I mean, and yes I use MySql.
I'll try to explain better 
In my database I type title_query(3), in my code I query the info from the database to the page, but before it ouputs the data to the website I want title_query($id) to be executed.
as far as i know theres no internal function 'title_query' so i asume thats your php function.
code: $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');
$query = 'SELECT * FROM my_table';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
mysql_close($link);
to help theres a basic sql query
RE: php query help by Ezra on 08-03-2005 at 08:04 PM
Well... I have a basic lay-out and all the data is in the database. And if you change the id number the data changes but not the lay-out.
That's why I need to add the query to the database.
http://imdb.tsdme.nl/profile.php?id=1
http://imdb.tsdme.nl/profile.php?id=2
That's my function
code: function title_query($id){
global $title;
$title = mysql_fetch_array(mysql_query("SELECT `title` FROM `imdb_data_title` WHERE id=".$id));
echo $title['0'];
}
At the first link where it says title_query()(3), I want it to change to the title of the movie, that is stored in the database with that query
EDIT: Basicly I want to store a piece of my php code in my database to be executed later
RE: php query help by Ezra on 08-03-2005 at 11:19 PM
I tried and tried and tried, and couldn't get it working...
So I thought about another thing a function that looks for special tags and changes them to data from another table.
Example:
Ezra made a great movie called [[t13]] which is made in the year [[y13]] and is the next big hit next to [[t11]] made in [[y13]].
This means that the T stands for title of row 13, and Y for the year from row 13
Does anyone think he knows how to make this or help me to make this 
Any help is appreciated
RE: php query help by jren207 on 08-04-2005 at 01:31 AM
code: <?php
$id = $HTTP_GET_VARS['id'];
function query_db(){
global $id;
$query_q = mysql_query("SELECT * FROM imdb_data_title WHERE id = '$id'");
while($query_row = mysql_fetch_array($query_q)){
$output = ('<b>Title /b> <i>' . $query_row['title'] . '</i><b> Year b> <i>' . $query_row['year'] . '</i>');
}
return $output;
}
echo('' . query_db() . '');
RE: php query help by Ezra on 08-04-2005 at 01:20 PM
I had that already working , but my problem was that I had to store a part of the php code in the database and it wouldn't execute that part.
My version:
code: function title_query($id){
global $title;
$title = mysql_fetch_array(mysql_query("SELECT * FROM `imdb_data_title` WHERE id=".$id));
echo "<b>Title</b>: <i>".$title['title']."</i> <b>Year</b>: <i>".$title['year']."</i><br>";
}
RE: php query help by Eljay on 08-04-2005 at 01:37 PM
eval()
|