PDA

View Full Version : Custom Pages Pulling From Database


evenmonkeys
08-10-2005, 05:39 AM
I'm not really sure how to describe what I am looking for. I learned that what I had tried to do was not possible. Basically, I tried to use php within a vbphrase and within a template. Turns out I can't do that. I'm looking for a way that I can easily specify what I would like to pull from the database. Specify a table, the fields, and all that fun stuff. Think someone can think something up?

Here's an example of what I tried to do...

<table align="center" border="1" cellspacing="1" cellpadding="1">
<?PHP
$dbhost = 'localhost';
$dbuser = '';
$dbuserpassword = '';
$dbname = '';
$tablename = '';
$conn = mysql_connect("$dbhost", "$dbuser", "$dbuserpassword")
or die(mysql_error());
mysql_select_db("$dbname",$conn) or die(mysql_error());

$result = mysql_query("SELECT * FROM $tablename");
while($query_data = mysql_fetch_row($result)) {

echo "<tr><td width=125>", $query_data[1],"</td>";
echo "<td>", $query_data[4],"</td></tr>";
echo "<tr><td colspan=2>", $query_data[2],"</td></tr>";
echo "<tr><td colspan=2>", $query_data[3],"</td></tr>";

}
?>
</table>

This obviously doesn't work... so if you have a way to help me, please let me know. This would be a good hack. ^^

twoseven
08-10-2005, 12:48 PM
you would have to make a php file for it and including[code]global.php[/php] would get you access to all vb's functions unless you wanted it to pull from a secondary database

https://vborg.vbsupport.ru/showthread.php?t=62164 is the tutorial for making your own page

evenmonkeys
08-10-2005, 09:06 PM
I'm not really sure that's what I'm looking for. I also do not believe that works with 3.5. I made a new table in the database and I would like to be able to list what's in it. Looking at his hack, it doesn't seem as though I can do that. If I am able to do it, I am unsure of how to go about doing it.

twoseven
08-10-2005, 09:28 PM
that is just a tutorial and yes it is valid for 3.5 to acess a custom table you need to do your own querys select/writes etc.

evenmonkeys
08-11-2005, 03:41 AM
Well, let's pretend that I didn't know how to do my own queries and whatnot. How would I specify what tables and fields I wanted to use?