Jump to content

Lassie

Members
  • Posts

    390
  • Joined

  • Last visited

Posts posted by Lassie

  1. I have a simple site to build and am trying to includer a header file.

    My structure is to functions from an overall require file (ab_fns.php).

    At present there is only a display_fns.php to include. which loads a header and a stylesheet.

    This does not happen.

    Can anyone help please.

    link http://217.46.159.226/authorbank/index.php

    display_fns.php

     

    <?php
    
    function do_html_header()
    {
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Authorbank</title>
    
    <link href="./includes/layout.css media="screen"
    rel="stylesheet" type="text/style" />
    <?php	
    }
    ?>
    ab_fns.php
    [code]
    <?php
    include_once ('display_fns.php');
    
    ?>
    

    [/code]

     

  2. I now have a parse free script but my cat_id is not adding to the url.

    I have verified that the $row['cat_id'] holds the category.

     

    Can anyone help please.

    
    <?php
    			    // create a back link if current page greater than 0
    			    if ($curPage > 0) 
    				{
    				  echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage-1).'&cat_id='. ($row['cat_id']).'">< Prev</a>';
    				}
    			    // otherwise leave the cell empty
    			    else {
    				  echo ' ';
    				  }
    			    ?>
                        </td>
                        <?php
    			    // pad the final row with empty cells if more than 3 columns
    			    if (COLS-2 > 0) 
    				{
    				  for ($i = 0; $i < COLS-2; $i++) 
    				  {
    				    echo '<td> </td>';
    					}
    				}
    			    ?>
                        <td>
    				<?php
    			    // create a forwards link if more records exist
    			    if ($startRow+SHOWMAX < $totalPix) 
    				{
    				  echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage+1).'& cat_id='.($row['cat_id']).'">Next ></a>';
    				  }
    			    // otherwise leave the cell empty
    			    else {
    				  echo ' ';
    				  }
    			    ?>
                        </td>
                    </tr>
                	</table>
    

     

     

    Full script

    <?php
    include ('book_sc_fns.php');
      // The shopping cart needs sessions, so start one
      session_start();
      do_html_header();
      				$cat_id=$_GET['cat_id'];
      				$name = get_category_name($cat_id);
      
      		//define number of cols in the table
      					define('COLS',2);
      				//set maxium number of records per page
      					define('SHOWMAX',9);
      					
      				//connect to db
      				$connection = db_connect();
      				
      				//prepare sql to get total records
      				$getTotal = "SELECT COUNT(*) as cnt FROM products WHERE cat_id='$cat_id'";
      				//sunbit query and store results as $totalPix
      				$total = mysql_query($getTotal)or die ("Problem with the query: $getTotal<br>" . mysql_error());
      				$row = mysql_fetch_assoc($total);
      				$totalPix = $row['cnt'];
      				
      				//set the current page
      				$curPage = isset($_GET['curPage']) ? $_GET['curPage'] : 0;
    			// calculate the start row of the subset
    			$startRow = $curPage * SHOWMAX;
      				
      				$query = "SELECT *
                 			from products WHERE cat_id='$cat_id' LIMIT $startRow, ".SHOWMAX; 
      						$result = mysql_query($query)or die("Problem with query: $query<br>" . mysql_error());
      						if (!$result)
      						return false;
      						$num_cats = mysql_num_rows($result);
      						if ($num_cats ==0)
      						return false;
      						$row = mysql_fetch_assoc($result);
      
    	// get the name and caption for the main image
    		$mainImage = $row['pix'];
    
    
    		// get the name for the main image
    			if(isset($_GET['image']))
    			{
    				$mainImage = $_GET['image'];
    			}
    			else{
    				$mainImage = $row['pix'];
    			}
    	// get the dimensions of the main image
    		$imageSize = getimagesize('images/'.$mainImage);
    
    
    ?>			
        		
            	<h1 class="align-center"><?php echo $name;?></h1>
            	<p id="picCount">Displaying <?php echo $startRow+1;
    	  	if ($startRow+1 < $totalPix) 
    		  {
    	    echo ' to ';
    		if ($startRow+SHOWMAX < $totalPix) {
    		  echo $startRow+SHOWMAX;
    		  }
    		else {
    		  echo $totalPix;
    		  }
    		}
    	  	echo " of $totalPix";
    	  ?></p>
    	  	<div class="float-divider"></div>
      			<div id="gallery">
      			
                <table id="thumbs" align="center">
                    <tr>
    				<!--This row needs to be repeated-->
    
                        <?php
    					//initialised cell counter outside loop
    					$pos = 0;
    				 do 
    				{ 
    
    				  // set caption if thumbnail is same as main image
    	              if ($row['pix'] == $mainImage) {
    	                	$caption = $row['title'];
    	                	
    	                	$about=$row['product_desc'];
    		            }
    
    				 ?>
                        <td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?image=<?php echo $row['pix']; ?>&curPage=<?php echo $curPage; ?>"><img src="images/<?php echo $row['pix']; ?>" alt="<?php echo $row['title']; ?>" width="80" height="54" /></a></td>
                        <td class="thumbs"><?php echo $row['title'];?></td>
    				<?php
    				$row = mysql_fetch_assoc($result);
    				//increment counter after next row extracted 
    				$pos++;
    	  			// if at end of row and records remain, insert tags
    				if ($pos%COLS === 0 && is_array($row)) 
    				{
    	    		  echo '</tr><tr>';
    				  }
    	  			} while($row);  // end of loop
    	  			// new loop to fill in final row
    				while ($pos%COLS) 
    				{
    	    		  echo '<td> </td>';
    				  $pos++;
    			      }
    
    				?>
                    </tr>
    			<!-- Navigation link needs to go here -->
    
    			<td><?php
    			    // create a back link if current page greater than 0
    			    if ($curPage > 0) 
    				{
    				  echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage-1).'&cat_id='. ($row['cat_id']).'">< Prev</a>';
    				}
    			    // otherwise leave the cell empty
    			    else {
    				  echo ' ';
    				  }
    			    ?>
                        </td>
                        <?php
    			    // pad the final row with empty cells if more than 3 columns
    			    if (COLS-2 > 0) 
    				{
    				  for ($i = 0; $i < COLS-2; $i++) 
    				  {
    				    echo '<td> </td>';
    					}
    				}
    			    ?>
                        <td>
    				<?php
    			    // create a forwards link if more records exist
    			    if ($startRow+SHOWMAX < $totalPix) 
    				{
    				  echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage+1).'& cat_id='.($row['cat_id']).'">Next ></a>';
    				  }
    			    // otherwise leave the cell empty
    			    else {
    				  echo ' ';
    				  }
    			    ?>
                        </td>
                    </tr>
                	</table>
                	<div id="main_image">
                	<table align="center">
                	<tr>
                	<td colspan="2" align="center"><?php echo $caption; ?></td>
    			</tr>
                	<tr>
                	<td>
                    <p><img src="images/<?php echo $mainImage; ?>" alt="<?php echo $caption; ?>" <?php echo $imageSize[3]; ?> /></p>
    			</td>
    			<td><?php echo $about;?></td>
    			</tr></table>
                    
                </div>
            </div><!--End Div Gallery-->
        
        
        <?php
        
      	do_html_footer();
    exit();
    ?>
    
    

  3. Hi,

    Full code below and thank you for your interest.

    I have in this version error on 152.

    Now 152 is the same code almost as 131 which doesnt give an error.

     

    
    <?php
    include ('book_sc_fns.php');
      // The shopping cart needs sessions, so start one
      session_start();
      do_html_header();
      
      				$cat_id = $_GET['cat_id'];
      
      				$name = get_category_name($cat_id);
      				
      
      		//define number of cols in the table
      					define('COLS',2);
      				//set maxium number of records per page
      					define('SHOWMAX',9);
      				
      					
      				//connect to db
      				$connection = db_connect();
      			//	$cat_id=12;
      				
      				
      				//prepare sql to get total records
      				
      	$getTotal = "SELECT COUNT(*) as cnt FROM products WHERE cat_id='$cat_id'";
      	//sunbit query and store results as $totalPix
      	$total = mysql_query($getTotal) or die("Problem with the query: $getTotal<br>" . mysql_error());
      	$row = mysql_fetch_assoc($total);
      	$totalPix = $row['cnt'];
      				
      				
      				//set the current page
      				$curPage = isset($_GET['curPage']) ? $_GET['curPage'] : 0;
    			// calculate the start row of the subset
    			$startRow = $curPage * SHOWMAX;
      				
      				$query = "SELECT *
                 			from products WHERE cat_id='$cat_id'LIMIT $startRow, ".SHOWMAX; 
      						$result = mysql_query($query)or die("Problem with the query: $query<br>" . mysql_error());
      						if (!$result)
      						return false;
      						$num_cats = mysql_num_rows($result);
      						if ($num_cats ==0)
      						return false;
      						$row = mysql_fetch_assoc($result);
      						
      					
      
    	// get the name and caption for the main image
    		$mainImage = $row['pix'];
    
    
    
    		// get the name for the main image
    			if(isset($_GET['image']))
    			{
    				$mainImage = $_GET['image'];
    			}
    			else{
    				$mainImage = $row['pix'];
    			}
    	// get the dimensions of the main image
    		$imageSize = getimagesize('images/'.$mainImage);
    
    
    ?>			
        		
            	<h1 class="align-center"><?php echo $name;?></h1>
            	<p id="picCount">Displaying <?php echo $startRow+1;
    	  	if ($startRow+1 < $totalPix) 
    		  {
    	    echo ' to ';
    		if ($startRow+SHOWMAX < $totalPix) {
    		  echo $startRow+SHOWMAX;
    		  }
    		else {
    		  echo $totalPix;
    		  }
    		}
    	  	echo " of $totalPix";
    	  ?></p>
    	  	<div class="float-divider"></div>
      			<div id="gallery">
      			
                <table id="thumbs">
                    <tr>
    				<!--This row needs to be repeated-->
    
                        <?php
    					//initialised cell counter outside loop
    					$pos = 0;
    				 do 
    				{ 
    
    				  // set caption if thumbnail is same as main image
    	              if ($row['pix'] == $mainImage) 
    				  	{
    	                	$caption = $row['title'];
    	                	$about=$row['product_desc'];
    	                	
    		            }
    
    				 ?>
                        <td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?image=<?php echo $row['pix']; ?>&curPage=<?php echo $curPage; ?>"><img src="images/<?php echo $row['pix']; ?>" alt="<?php echo $row['title']; ?>" width="80" height="54" /></a>
    				</td>
                        <td class="thumbs"><?php echo $row['title'];?></td>
    				<?php
    				$row = mysql_fetch_assoc($result);
    				//increment counter after next row extracted 
    				$pos++;
    	  			// if at end of row and records remain, insert tags
    				if ($pos%COLS === 0 && is_array($row)) 
    				{
    	    		  echo '</tr><tr>';
    				  }
    	  			} while($row);  // end of loop
    	  			// new loop to fill in final row
    				while ($pos%COLS) 
    				{
    	    		  echo '<td> </td>';
    				  $pos++;
    			      }
    
    				?>
                    </tr>
    			<!-- Navigation link needs to go here -->
    
    			<td><?php
    			    // create a back link if current page greater than 0
    			    if ($curPage > 0) {
    				  echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage-1).'&cat_id='.($row['cat_id']).">< Prev</a>';
    				  }
    			    // otherwise leave the cell empty
    			    else {
    				  echo ' ';
    				  }
    			    ?>
    			    </td>
    			    <?php
    			    // pad the final row with empty cells if more than 2 columns
    			    if (COLS-2 > 0) {
    				  for ($i = 0; $i < COLS-2; $i++) {
    				    echo '<td> </td>';
    				    }
    				  }
    			    ?>
                        <td>
    				<?php
    			    // create a forwards link if more records exist
    			    if ($startRow+SHOWMAX < $totalPix) 
    				{
    				echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage+1).'& cat_id='.($row['cat_id']).">> Next</a>';
    			 	}
    			    // otherwise leave the cell empty
    			    else {
    				  echo ' ';
    				  }
    			?>
                        </td>
                    </tr>
                	</table>
                	<div id="right">
                	<table width="350" align="center">
                	<tr>
                	<td colspan="2" align="center"><?php echo $caption; ?></td>
    			</tr>
                	<tr>
                	<td>
                    <p><img src="images/<?php echo $mainImage; ?>" alt="<?php echo $caption; ?>" <?php echo $imageSize[3]; ?> /></p>
    			</td>
    			<td><?php echo $about;?></td>
    			</tr></table>
                    
                </div>
            </div><!--End Div Gallery-->
        
        
        <?php
        
      	do_html_footer();
    exit();
    ?>
    

  4. I have a page which displays books in a selected category.The selected category is passed in the url. When a thumbnail is selected a larger image and book deatils are shown

    I want to display a limited no of books and use a prev and next link to allow all to be shown.

    To do this the page use SERVER_SELF.

    I have 2 problems.

    1. When I select a thumbnail for the full details to be shown I loose the cat id as it is passed in the Get method.

    2. I have tried adding the cat id to the prev and next links but this produces a parse error.

    I think I will also have to amend the thumbnail link.

     

    Is what I am trying to do possible and how do I correct the syntax.

     

    The parse error lines are below followed by the script.

    echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage-1).'&cat_id='.($row['cat_id']).">< Prev</a>';
    
    [code]
    
    echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage+1).'& cat_id='.($row['cat_id']).">Next ></a>';
    
    [code]
    
    <?php
    include ('book_sc_fns.php');
      // The shopping cart needs sessions, so start one
      session_start();
      do_html_header();
      
      				$cat_id = $_GET['cat_id'];
      
      				$name = get_category_name($cat_id);
      				
      
      		//define number of cols in the table
      					define('COLS',2);
      				//set maxium number of records per page
      					define('SHOWMAX',9);
      				
      					
      				//connect to db
      				$connection = db_connect();
      			//	$cat_id=12;
      				
      				
      				//prepare sql to get total records
      				
      	$getTotal = "SELECT COUNT(*) as cnt FROM products WHERE cat_id='$cat_id'";
      	//sunbit query and store results as $totalPix
      	$total = mysql_query($getTotal) or die("Problem with the query: $getTotal<br>" . mysql_error());
      	$row = mysql_fetch_assoc($total);
      	$totalPix = $row['cnt'];
      				
      				
      				//set the current page
      				$curPage = isset($_GET['curPage']) ? $_GET['curPage'] : 0;
    			// calculate the start row of the subset
    			$startRow = $curPage * SHOWMAX;
      				
      				$query = "SELECT *
                 			from products WHERE cat_id='$cat_id'LIMIT $startRow, ".SHOWMAX; 
      						$result = mysql_query($query)or die("Problem with the query: $query<br>" . mysql_error());
      						if (!$result)
      						return false;
      						$num_cats = mysql_num_rows($result);
      						if ($num_cats ==0)
      						return false;
      						$row = mysql_fetch_assoc($result);
      						
      					
      
    	// get the name and caption for the main image
    		$mainImage = $row['pix'];
    
    
    
    		// get the name for the main image
    			if(isset($_GET['image']))
    			{
    				$mainImage = $_GET['image'];
    			}
    			else{
    				$mainImage = $row['pix'];
    			}
    	// get the dimensions of the main image
    		$imageSize = getimagesize('images/'.$mainImage);
    
    
    ?>			
        		
            	<h1 class="align-center"><?php echo $name;?></h1>
            	<p id="picCount">Displaying <?php echo $startRow+1;
    	  	if ($startRow+1 < $totalPix) 
    		  {
    	    echo ' to ';
    		if ($startRow+SHOWMAX < $totalPix) {
    		  echo $startRow+SHOWMAX;
    		  }
    		else {
    		  echo $totalPix;
    		  }
    		}
    	  	echo " of $totalPix";
    	  ?></p>
    	  	<div class="float-divider"></div>
      			<div id="gallery">
      			
                <table id="thumbs">
                    <tr>
    				<!--This row needs to be repeated-->
    
                        <?php
    					//initialised cell counter outside loop
    					$pos = 0;
    				 do 
    				{ 
    
    				  // set caption if thumbnail is same as main image
    	              if ($row['pix'] == $mainImage) 
    				  	{
    	                	$caption = $row['title'];
    	                	$about=$row['product_desc'];
    	                	
    		            }
    
    				 ?>
                        <td><a href="<?php echo $_SERVER['PHP_SELF']; ?>?image=<?php echo $row['pix']; ?>&curPage=<?php echo $curPage; ?>"><img src="images/<?php echo $row['pix']; ?>" alt="<?php echo $row['title']; ?>" width="80" height="54" /></a>
    				</td>
                        <td class="thumbs"><?php echo $row['title'];?></td>
    				<?php
    				$row = mysql_fetch_assoc($result);
    				//increment counter after next row extracted 
    				$pos++;
    	  			// if at end of row and records remain, insert tags
    				if ($pos%COLS === 0 && is_array($row)) 
    				{
    	    		  echo '</tr><tr>';
    				  }
    	  			} while($row);  // end of loop
    	  			// new loop to fill in final row
    				while ($pos%COLS) 
    				{
    	    		  echo '<td> </td>';
    				  $pos++;
    			      }
    
    				?>
                    </tr>
    			<!-- Navigation link needs to go here -->
    
    			<td><?php
    			    // create a back link if current page greater than 0
    			    if ($curPage > 0) {
    				  echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage-1).'&cat_id='.($row['cat_id']).">< Prev</a>';
    				  }
    			    // otherwise leave the cell empty
    			    else {
    				  echo ' ';
    				  }
    			    ?>
                        </td>
                        <?php
    			    // pad the final row with empty cells if more than 2 columns
    			    if (COLS-2 > 0) {
    				  for ($i = 0; $i < COLS-2; $i++) {
    				    echo '<td> </td>';
    				    }
    				  }
    			    ?>
                        <td>
    				<?php
    			    // create a forwards link if more records exist
    			    if ($startRow+SHOWMAX < $totalPix) {
    				  echo '<a href="'.$_SERVER['PHP_SELF'].'?curPage='.($curPage+1).'& cat_id='.($row['cat_id']).">Next ></a>';
    				  }
    			    // otherwise leave the cell empty
    			    else {
    				  echo ' ';
    				  }
    			    ?>
                        </td>
                    </tr>
                	</table>
                	<div id="right">
                	<table width="350" align="center">
                	<tr>
                	<td colspan="2" align="center"><?php echo $caption; ?></td>
    			</tr>
                	<tr>
                	<td>
                    <p><img src="images/<?php echo $mainImage; ?>" alt="<?php echo $caption; ?>" <?php echo $imageSize[3]; ?> /></p>
    			</td>
    			<td><?php echo $about;?></td>
    			</tr></table>
                    
                </div>
            </div><!--End Div Gallery-->
        
        
        <?php
        
      	do_html_footer();
    exit();
    ?>
    

    [/code]

    [/code]

  5. Thanks for coming back.

    The variable is declared further in the code as shown below.

    I am trying to retrieve a set of records based on the catagory id and then display a thumbnail gallery from which the selected image is displayed along with other details.

    The gallery could have a lot of images so I want paginate the results.Count is to get the totla no of images/records.

     

    //define number of cols in the table
      					define('COLS',3);
      				//set maxium number of records per page
      					define('SHOWMAX',9);
      				
      					
      				//connect to db
      				$connection = db_connect();
      				$cat_id=12;
      				
      				//prepare sql to get total records
      				$getTotal = "SELECT COUNT(*)FROM products WHERE cat_id={'$cat_id'}";
      				//sunbit query and store results as $totalPix
      				$total = mysql_query($getTotal);
      				$row = mysql_fetch_row($total);
      				$totalPix = $row[0];
      				echo"$totalPix";
      				
    
    

  6. I want to count the result of a query using count and have an ivalid resource message.

    Why is the code in error?

    //prepare sql to get total records
      				$getTotal = "SELECT COUNT(*)FROM products WHERE cat_id=$cat_id'";
      				//sunbit query and store results as $totalPix
      				$total = mysql_query($getTotal);
      				$row = mysql_fetch_row($total);
      				$totalPix = $row[0];
      				echo"$totalPix";
      				
    
    

    I get no result when echo $totalPix;

  7. I have a function to retireve books in a category selection.

    The function returns an array of books.

    I also want to return the number of books in the category so I can go on and paginate the results.

    How can I include the variable $num_books with the return result?

     

    function get_books($cat_id)
    {
       // query database for the books in a category
       if (!$cat_id || $cat_id=='')
         return false;
       
       $query = "select * from products where cat_id='$cat_id'";
       $result = mysql_query($query);
      if (!$result)
      return false;
       $num_books = mysql_num_rows($result);
       if ($num_books ==0)
          return false;
       $result = db_result_to_array($result);
       return $result;
    }
    

  8. Thanks.

    I tried the following and it worked.So i now have 2 solutions.

    how do i post as solved?

    echo "<a href=\"show_book.php?product_id={$row['product_id']}\" onmouseover=\"ajax_showTooltip('demo-pages/js-calendar.html',this);return false\" onmouseout=\"ajax_hideTooltip()\">
               <img src= './images/{$row['pix']}' border='0'
                  width='100' height='80' /></a>";
    

  9. I have an image link with a js call to show a tootip.

    I have a parse error onhe first line.

    Can anyone help please?

    <td class="p1"><a href="<?php echo('show_book.php?product_id={$row['product_id']}');?>>
            	<img src=<?php echo './images/{$row['pix']}';?> border="0"
                  width="80" height="100">onmouseover="ajax_showTooltip('demo-pages/js-calendar.html',this);return false" onmouseout="ajax_hideTooltip()"</a>"
    

  10. This may not seem like a php question but the code is tied into php.

    I have a simple menu that should dipslay a customised bullet against each item and change when the item is selected ( from bullet to arrow)

    The images dont display.

    The list is populated from a db using php and the links are made from a function.

    The site link is http://217.46.159.226/e_cart22/

    The menu is select e-books cataegory.

    Any help appreciated.

    The css is

    Code:

     

    #cats {

      margin-top: 5px;

      float:left;

    }

     

    #cats td.head {

      text-align:center;

      width:180px;

      background-color: gray;

      color: #FFFFFF;

      font-size: 90%;

    }

    #cats ul {

    list-style-type: none;

    margin-left: 0px;

    padding-left: 0px;

    }

     

    .custom {

    list-style-image:url('./images/bullet_cat.gif');

    }

    #cats li {

    list-style-type: none;

    background-image: url(./'images/arrow_green.gif');

    background-repeat: no-repeat;

    background-position:0px 2px;

    padding-left: 30px;

    padding-top: 2px;

    padding-bottom: 2px;

    margin-bottom: 2px;

     

     

    }

    div#cats li a:link {

    text-decoration: none;

    color: #00AEED;

    font-weight: bold;

    }

     

    div#cats li a:visited {

    text-decoration: none;

    color: #00AEED;

    font-weight: bold;

    }

    div#cats li a:hover {

    text-decoration: none;

    color: #FF0000;

    font-weight: bold;

    }

     

    div#cats li a:active {

    text-decoration: none;

    }

     

    The mark up is

    Code:

     

    echo '<table>';/*set overall table*/

      echo '<tr><td valign="top">';/*set first row and cell in overall table for cats*/

      echo '<div id="cats">';

      echo '<table width="180" border="1" valign="top">';/*set table for cats*/

      echo '<tr><td class="head" >Select an E-Book Category</td></tr>';/*set title cell*/

     

      echo '<tr><td>';/* set table row and cell for cats*/

      echo '<ul>';

      foreach ($cat_array as $row)

      {

        $url = 'show_cat.php?cat_id='.($row['cat_id']);

        $title = $row['cat_description'];

     

    ?>

    <li class="custom">

    <a href="<?php echo $url; ?>"><?php echo $title; ?></a><br />

     

        </li>

        <?php

      }

       

      echo '</ul>';

     

    the function for the link is

    Code:

     

    function do_html_URL($url, $title)

    {

      // output URL as link and br

    ?>

      <a href="<?php echo $url; ?>"><?php echo $title; ?></a><br />

    <?php

    }

     

     

  11. Here is the full page in al its glory.

    Thanks for your interest.

    <?php
    require ('book_sc_fns.php');
    include_once('./includes/config.inc.php');
    session_start();
    
    do_html_header();
    
    
    // get categories out of database
      $cat_array = get_categories();
    
      // display as links to cat pages
      display_categories($cat_array);
      
      
    //get featured books
    
    $connection = db_connect();
      $query = "select * From products WHERE Featured='1' Order by cat_id";
      $result = mysql_query($query);
      if (!$result)
      return false;
      $num_cats = mysql_num_rows($result);
      if ($num_cats ==0)
      return false;
      
    echo '<td>';/* set cell for contents within overall table*/
    echo'<div id="contents">';
    echo'<table  width="600" border="0" cellpadding="50" cellspacing="5" >';
    //echo"<caption>Welcome to e-Books4U electronic Book store</caption>";
    echo'<thead><tr><td  colspan="5" ><h6>This Months Featured e-Books</h6></td></tr>
    </thead>';
      $i=0;
      $size=3;
      echo "<tbody>";
        echo "<tr>";
      while ($row = mysql_fetch_array($result,MYSQL_ASSOC))   
      {
        /* display picture  */
        
        ?>
        <td class="p1">
        <td><a href="<?php echo'show_book.php?product_id={$row['product_id']}';?>>
            	<img src=<?php echo './images/{$row['pix']}';?> border='0'
                  width='80' height='100'>onmouseover="ajax_showTooltip('demo-pages/js-calendar.html',this);return false" onmouseout="ajax_hideTooltip()"</a>"
        
      	<?php
    /* display row for each featured book */
    $url= 'show_book.php?product_id='.($row{'product_id'});
        $title = $row['title'];
        do_html_url($url,$title);
        echo "ONLY<br />";
        echo "£{$row['price']}</td>";
        $i++;
        
        if($i==$size)
    {
      echo "</tr><tr>";
      
      $i=0;
    }
        
    }
      echo "<tr><td colspan='5'><h6>Latest Additions to the e-book catalog</h6></td></tr>";
      
      //get Latest Additions
      
      $connection = db_connect();
      $query = "select * From products WHERE New='1' Order by cat_id";
      $result = mysql_query($query);
      if (!$result)
      return false;
      $num_cats = mysql_num_rows($result);
      if ($num_cats ==0)
      return false;
      
      echo "<tr>";
      while ($row = mysql_fetch_array($result,MYSQL_ASSOC))   
      {
        /* display picture  */
        
        echo "<td><a href='show_book.php?product_id={$row['product_id']}'>
            	<img src= './images/{$row['pix']}' border='0'
                  width='100' height='80'></a><br />";
    
    /* display row for each featured book */
    $url= 'show_book.php?product_id='.($row{'product_id'});
        $title = $row['title'];
        do_html_url($url,$title);
        echo "Special Price <br />";
        echo "£{$row['price']}</td>";
        $i++;
        
        if($i==$size)
    {
      echo "</tr><tr>";
      
      $i=0;
    }
        
    }
    	echo "<tr><td text-align='center' colspan='5'><h6>Bargin e-books that can get you started in business today</h6></td></tr>";  
    
    	//get business ebooks
      
      $connection = db_connect();
      $query = "select * From products WHERE  business='1'  Order by cat_id";
      $result = mysql_query($query);
      if (!$result)
      return false;
      $num_cats = mysql_num_rows($result);
      if ($num_cats ==0)
      return false;
      
      echo "<tr>";
      while ($row = mysql_fetch_array($result,MYSQL_ASSOC))   
      {
        /* display picture  */
        
        echo "<td><a href='show_book.php?product_id={$row['product_id']}'>
            	<img src= './images/{$row['pix']}' border='0'
                  width='100' height='80'></a><br />";
                  
    /* display row for each business book */
    $url= 'show_book.php?product_id='.($row{'product_id'});
        $title = $row['title'];
        do_html_url($url,$title);
        echo "Special Price";
        echo "£{$row['price']}<br />";
        echo "<a href='./business/{$row['promo_link']}'>Read Review</a></td>\n";
        $i++;
        
        if($i==$size)
    {
      echo "</tr><tr>";
      
      $i=0;
    }
        
    }
      
      echo "</tbody></table>\n";/* end contents table*/
      echo "</div>";/* end contents div */
      echo '</td>';/* end overall contents cell*/
      echo '</tr></table>';/* end overall table row and table*/
    /* echo '</div>';/* end home div*/
      
    do_html_footer();
    exit;
    ?>
    
    /* 
      
      // if logged in as admin, show add, delete, edit cat links
    if(isset($_SESSION['admin_user']))
      {
        display_button('admin.php', 'admin-menu', 'Admin Menu');
      }*/
    
    
    
    

  12. Ok I tried this. No good yet.

    <?php
      echo'  <a href="('show_book.php?product_id={$row['product_id']}')?>"onmouseover="ajax_showTooltip('demo-pages/js-calendar.html',this);return false" onmouseout="ajax_hideTooltip()"<?php('show_book.php?product_id={$row['product_id']}')?><img src= <?php'./images/{$row['pix']}'?> border="0" width="100" height="80"></a>';
                  
    
    

  13. I have modified the script to this. Still parse error.

    Can anybody help please.

    <a href="<?php('show_book.php?product_id={$row['product_id']}')?>"onmouseover="ajax_showTooltip('demo-pages/js-calendar.html',this);return false" onmouseout="ajax_hideTooltip()"<?php('show_book.php?product_id={$row['product_id']}')?><img src= <?php'./images/{$row['pix']}'?> border="0" width="100" height="80"></a>
    
    

×
×
  • 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.