Jump to content

Generating pages?


GwarSlave1673

Recommended Posts

Can anyone point me towards a tutorial or a book or anything that will show me how to do the following.

 

I have a website that allows users to submit information on Halloween attractions (like haunted houses) to a mysql database and I'm trying to find a way to make the attractions automatically added to a list of attractions without me have to go in and plug them into a html file and add the link to the list of attractions. 

 

I've bought several books on php and mysql and none of them cover this. They all tell how to output the data in an array but I'm not really looking to make the data a table.  I want it to be a list of attractions and users can click on the name of an attraction and it take them to a page on that attraction.

 

If anyone would like to look at the page and give advice on other stuff as well you can see the site here.  http://www.nchaunts.com/new/index.html

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/47923-generating-pages/
Share on other sites

Do you mean something like read the items from the database table and then generate the html for display ?

 

If so this is something kind of similiar using mysql  8)

 

First function to select the rows something like :-

 


function sel_rows($tabname)
{
        global $dbname;
        global $host;
        global $id;
        global $pwd;

        /* Create connection                                          */
$connection = connect_db($host, $id, $pwd);

        /* Select database                                            */
$thisdb = @mysql_select_db($dbname, $connection)
	or die(mysql_error());

        /* Set query string                                           */
$query = "select * from ".$tabname;

        /* Call query execution function returning link to result set */
$result = mysql_query($query, $connection) 
	or die(mysql_error());

        /* explicitly destroy the connection                          */
        connect_close($connection);

       return $result;
}

 

Then something that calls sel_rows and builds the html in a string n.b. some folks don't like the way I build up strings in chunks :-

 


function stock_list()
   {

        $result=sel_rows("product");
        $str = "<table cellspacing=\"3\" cellpadding=\"3\" border=\"2\"><th>Product</th><th>Free Stock</th><th>Price</th>";
        while ($row=mysql_fetch_array($result))
        {
   $prod = $row['product'];
   $stock = $row['stock'];
                $price = $row['price'];
                $str .= "<tr>";
                $str .= "<td valign='center'>";
	$str .= $prod;
	$str .= "</td>";
                $str .= "<td valign='center'>";
	$str .= $stock;
	$str .= "</td>";
                $str .= "<td valign='center'>&pound";
	$str .= number_format($price, 2, '.', '');
	$str .= "</td>";
	$str .= "</tr>";
        }
$str.= "</table>";
echo $str;
   }

 

It won't work verbatim for your app but should give you ideas - that's if I've understood your problem correctly !!

Link to comment
https://forums.phpfreaks.com/topic/47923-generating-pages/#findComment-234237
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.