Current location: Hot Scripts Forums » Programming Languages » PHP » code trouble


code trouble

Reply
  #1 (permalink)  
Old 09-03-10, 10:03 PM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 122
Thanks: 2
Thanked 0 Times in 0 Posts
code trouble

Hi guys i have this code but it does not give results

Code:
<?php

 $error = "Could not connect to the database";
 mysql_connect('localhost','root','')   or die($error);
 mysql_select_db('hairsalon') or die($error);
 //max displayed per page
 $per_page = 2;

 //get start varible

 $start = $_GET['start'];

 //count records

 $record_count = mysql_num_rows (mysql_query("SELECT * FROM products"));

 //count max pages

 $max_pages = $record_count / $per_page; // may come out as decimal

 if (!$start)
    $start =0;

 //display data

 $get = mysql_query("SELECT  prodid, name, description, picturename  FROM products ORDER BY name LIMIT $start, $per_page");

echo "<table  summary='Services, or Links box template' class='servicesT' cellspacing='0'>";
echo"<br>";
echo "<tr> <th align= left>Name</th>  <th align= left colspan='0'>Description</th> <th align= left colspan='0'>Picture</th>";
echo"<p>";
  while ($row = mysql_fetch_assoc($get))
  {
     // get data
        $prodid = $row['prodid'];
        $name = $row['name'];
        $description = $row['description'];
        $picturename = $row['picturename'];

      echo "<a href=\"index.php?&content=updatetutor&id=$prodid\">";
      echo strtoupper("<tr><td class='servBodL' width=25%><b><u>$name</td>\n");
      echo "<p>";
      echo strtoupper("<td class = 'servBodL' width= 30%>$description</td>");
      echo "<p>";
      echo strtoupper("<td class = 'servBodL' width= 30%>$picturename</td>");
      echo "<p>";





  }
    echo" </table> ";
   echo"<br>\n";
   //SETUP PREV AND NEXT VARIABLES

   $prev = $start - $per_page;

   $next = $start + $per_page;

   // show pre button

   if(!($start< 1))

   echo "<a href='index.php?content=ourproducts&start=$prev'>Prev</a>\n";
   //show page numbers

   //set variable for first page

   $i=1;

   for($x=0; $x<$record_count; $x=$x+$per_page)
   {

     if($start!=$x)

     echo "<a href='index.php?content=ourproducts&start=$x'>$i</a>\n";

     else

     echo "<a href='index.php?content=ourproducts&start=$x'>$i</b></a>\n";
     $i++;
   }


    if (!($start>=$record_count=$per_page))
   echo "<a href='index.php?content=ourproducts&start=$next'>Next</a>\n";

   echo "<br>";
?>
This is the error i recieve

Notice: Undefined index: start in C:\wamp\www\hairsalon2\includes\ourproducts.inc.ph p on line 11

and i have the pictures in a file called images, and it does not show the pictures



CAN ANY ONE HELP ME PLEASE!!!

Last edited by digioz; 09-05-10 at 01:26 PM. Reason: Please use code tags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 09-04-10, 12:30 PM
Wolf1994 Wolf1994 is offline
Wannabe Coder
 
Join Date: Sep 2005
Location: Russia
Posts: 117
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Notice: Undefined index: start in C:\wamp\www\hairsalon2\includes\ourproducts.inc.ph p on line 11
That's not the error. Use check like:
Code:
if(isset ($_GET['start']))
 $start = $_GET['start'];
else
 $start="";
to avoid this notice.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 09-05-10, 10:49 AM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 122
Thanks: 2
Thanked 0 Times in 0 Posts
thank you it works


but now it does not show the pictures can u help me with it plealse
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 09-05-10, 11:03 AM
Wolf1994 Wolf1994 is offline
Wannabe Coder
 
Join Date: Sep 2005
Location: Russia
Posts: 117
Thanks: 0
Thanked 0 Times in 0 Posts
Did it show them before?

Try to add or die(mysql_error()); to each sql query, like:
Code:
mysql_query("SELECT * FROM products") or die (mysql_error());
to check if they all correct.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 09-05-10, 11:11 AM
williamh26 williamh26 is offline
Wannabe Coder
 
Join Date: Jul 2010
Posts: 122
Thanks: 2
Thanked 0 Times in 0 Posts
the pictures images are on a file??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 09-09-10, 01:21 PM
Golith Golith is offline
Newbie Coder
 
Join Date: Jun 2010
Posts: 87
Thanks: 6
Thanked 1 Time in 1 Post
where is picturename

if picture name is held in a file then why is it being queried in sql
my suggestion would be to enter a file location in picture name field on db so u can pull it and use it or better still hold th e image on the db.

would make things easier
__________________
Its My script and I'll if I want to
www.cictradinggroup.com.au
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Google Ad Rotation Code LaPirata Script Requests 6 12-29-10 04:31 AM
how to handle search function code.. Miben PHP 5 03-24-09 01:56 AM
Need captcha for html+php contact form sujata_ghosh PHP 6 03-22-09 04:46 PM
Zip Code search range errors Merovingian PHP 2 02-09-06 04:33 PM
How to sale php code to customer without giving him code pradeep_soft PHP 4 03-12-04 01:10 PM


All times are GMT -5. The time now is 08:41 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.