1,075,763 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?

Posts by sjeggels

Hey Ardav,
Thanks for the help. I will implement your suggestion and see how far I get.
Regards
Steven

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi there,

I am looking for help to code a php mysql search form with 4 dropdown list. I want the user to search for accommodation establishments by using a citytown, tourism route, accommodation profile and accommodation tariffs. All this will be in the dropdown list which reflects the fields in the database table users. I can connect to the database but cannot get my head around how to code the php script to get results for all fopur fields from the database. Also if the users only select one, two or three of the dropdown lists how do I code that the specific result is only returned in the search.

Woiuld appreciate if anyone can point me in the right direction for me to strat learning. herewith my code so far:

<?php
include 'dbc.php';
include 'classes/selectbox.php';
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="" method="post" name="myform" id="myform">

<h2>Search Accommodation:</h2> 
        <table width="90%" border="0" align="center" cellpadding="3" cellspacing="3" class="forms">

        <tr>
                <td>CityTown<span class="required">*</span><br />
                    <?php
        $mybox = new SelectionBox();
//This is the name of the selection box
$mybox->SetName("citytown");
//This is how to set an option and its value
$mybox->SetOption("Jeffreys Bay","Jeffreys Bay");
$mybox->SetOption("St Francis Bay","St Francis Bay");
$mybox->SetOption("Port Elizabeth","Port Elizabeth");
$mybox->SetOption("Cape St Francis","Cape St Francis");
$mybox->SetOption("Humansdorp","Humansdorp");
$mybox->SetOption("Oyster Bay","Oyster Bay");
//Finally, we output the box and specify which option value we want selected
$mybox->CreateBox("citytown");
?></td></tr>
<tr>
              <td>Tourism Route<span class="required">*</span><br />
                    <?php
        $mybox = new SelectionBox();
//This is the name of the selection box
$mybox->SetName("tourism_route");
//This is how to set an option and its value
$mybox->SetOption("Kouga Tourism Route","Kouga Tourism Route");
$mybox->SetOption("Tsitsikamma Tourism Route","Tsitsikamma Tourism Route");
$mybox->SetOption("Sunshine Coast","Sunshine Coast");
$mybox->SetOption("Greater Addo Route","Greater Addo Route");
//Finally, we output the box and specify which option value we want selected
$mybox->CreateBox("tourism_route");
?>                </td>
              </tr>
<tr>
                <td>Acc Category<span class="required">*</span><br />
                    <?php
        $mybox = new SelectionBox();
//This is the name of the selection box
$mybox->SetName("acc_category");
//This is how to set an option and its value
$mybox->SetOption("Bed & Breakfast","Bed & Breakfast");
$mybox->SetOption("Guest House","Guest House");
$mybox->SetOption("Selfcatering","Selfcatering");
$mybox->SetOption("Hotel","Hotel");
$mybox->SetOption("Lodge","Lodge");
$mybox->SetOption("Backpacker","Backpacker");
//Finally, we output the box and specify which option value we want selected
$mybox->CreateBox("acc_category");
?></td></tr>

             <tr>
              <td>Accommodation Tariffs<span class="required">*</span><br />
                    <?php
        $mybox = new SelectionBox();
//This is the name of the selection box
$mybox->SetName("acc_tariffs");
//This is how to set an option and its value
$mybox->SetOption("R0 - R350.00","R0 - R350.00");
$mybox->SetOption("R350.00 - R550.00","R350.00 - R550.00");
$mybox->SetOption("R550.00 - R850.00","R550.00 - R850.00");
$mybox->SetOption("R850.00 - R1 000.00","R850.00 - R1 000.00");
//Finally, we output the box and specify which option value we want selected
$mybox->CreateBox("acc_tariffs");
?></td></tr>

    <tr>

    <td>

    <input name="submit" type="submit" value="Search"/>
    </p> 
    </td>

    </tr>          
</table>
</form>

</body>
</html>

Also herewith the php class for the dropdown lists I am using:

<?php

/**
 SelectionBox class
 */
class SelectionBox
{
function SetName($name)
{
    $this->myname = $name;
    }
    function SetOption($optionvalue,$optionname)
    {
        $this->options[$optionname]=$optionvalue;
        }
        function CreateBox($selected)
        {
        if($this->options)
        {
            print "<SELECT name='".$this->myname."'>\n";
            //Create Options
            foreach($this->options as $optionname=>$optionvalue)
            {
                print "<OPTION value ='$optionvalue'";
                //Check if option should be selected
                if($selected == $optionvalue)
                {
                    print "SELECTED";
                }
                print ">$optionname</OPTION>\n";
            }
            print "</SELECT>";
        }
        else
        {
            print "Error: No options specified";
        }
    }
}
/*
$mybox = new SelectionBox();
//This is the name of the selection box
$mybox->SetName("MySelectionBox");
//This is how to set an option and its value
$mybox->SetOption("EU","Europe");
$mybox->SetOption("IN","India");
$mybox->SetOption("MX","Mexico");
//Finally, we output the box and specify which option value we want selected
$mybox->CreateBox("MX");
*/
?>
sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

hey magicmedia your suggestion worked fine. my next question is how do i display post/comments of my blog on the index page of my website. thanks.

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi everyone. I have a website setup and want to add a blog to the site. On my navigation bar i want to have a link to the main (say we call it index.php) page of my blog. I have installed wordpress v3 successful in a folder named blog in the root dir of my site (www.example.com/blog/). I added blog to nav bar but are stuck how to make it a link (link to my blog). Any helpl/tutorial would be appreciated.

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hielo, apologies for late reply. Your suggestions worked for dynamic link problem i had. Appreciate your help. Will mark this post as solved. Thanks

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

hielo. i tried your suggestion but i get a pass error. any reason why?

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hielo, Herewith my code for my profile.php page. Once again thank you for taking the time to look at this problem for me.

<?php
include 'dbc.php';
include 'includes/title.inc.php';
page_protect();

//retrieve the user's info
$q = "SELECT * FROM users where id='$_SESSION[user_id]'" ;
$res_q = mysql_query($q);
if(!$res_q){
echo mysql_error();
}else{
$row = mysql_fetch_assoc($res_q);
}
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="css/default.css" rel="stylesheet" type="text/css" />
<title>Places To Stay In The Eastern Cape<?php if (isset($title)) {echo "&#8212;{$title}";} ?></title>
<script language="JavaScript" type="text/javascript" src="javascripts/jquery-1.3.2.min.js"></script>
<script language="JavaScript" type="text/javascript" src="javascripts/jquery.validate.js"></script>
<script language="javascript" type="text/javascript" src="javascripts/textcount.js"></script>
  <script>
  $(document).ready(function(){
    $("#myform").validate();
	 $("#pform").validate();
  });
  </script>
</head>

<body>
<div id="wrapper">
<div id="topinfobar">
<p><span class="strapline">Magazine Shelf Life: </span>June - August 2010: <span class="style1">3 Months</span></p>
</div>

  <div id="topbanner1"></div>
   <div id="topbanner2"></div>
    <div id="topbanner3"></div>
     <div id="topbanner4"></div>
  
  <div id="cornerbox"></div>
  
  <div id="starlogo"></div>
  
  <div id="tourinfobar">
  <p class="intro">Accommodation Directory to the Eastern Cape's nine tourism routes:</p>
  <p>Tsitsikamma Route  |  Kouga Route  | Sunshine Coast | Frontier Country             
| Friendly N6 <br/> 
Karoo Heartland  | Greater Addo Route | Amatola Mountain Escape | Wildcoast/Cintsa</p>
  
  </div>
  
  <div id="info1"></div>
  
  <div id="topnavbar">
  <div id="topnav">
<?php include('includes/menu.inc.php'); ?>
</div>
  
  </div>
  <div id="user_register">
   <table width="100%" border="0" cellspacing="0" cellpadding="0" class="main">
<tr>
      <td>&nbsp;</td>
    </tr>
  <tr>
      <td valign="top"><?php 
/*********************** MYACCOUNT MENU ****************************
This code shows my account menu only to logged in users. 
Copy this code till END and place it in a new html or php where
you want to show myaccount options. This is only visible to logged in users
*******************************************************************/
if (isset($_SESSION['user_id'])) {?>
        <div id="menu">
            <p><strong>My Account</strong></p> 
            <ul>     
          <li><a href="myaccount.php">My Account</a></li>
            <li><a href="register.php">Register Details </a></li>
            <li><a href="imageupload.php">Upload Picture </a></li>
            <li><a href="profile.php">User Profile </a></li>
            <li><a href="mysettings.php">Update Details</a></li>
            <li><a href="list_users.php">View Users</a></li>
            <li><a href="logout.php">Logout </a></li>
          </ul>
          </div>
        <?php } 
/*******************************END**************************/
?>
          <p>&nbsp; </p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p></td>
    <td colspan="3" valign="top"><h3 class="titlehdr">User Profile</h3>
    
    <p>
            <?php	
      if (isset($_GET['msg'])) {
	  $message = urlencode($_GET['msg']);
	  echo "<div class=\"msg\">$message</div>";
	  }
	  ?>
          </p>
    
    <p>Here you can view your registered profile. Use the links at the bottom of this page should you wish to register a new account, upload a picture or update your details.</p>   
    <table width="80%" border="0" cellspacing="3" cellpadding="0">
    <tr>
    <td class="tduser"><h1>Date Registered:</h1><?php echo $row['date_registered'];?></td>
    <td rowspan="4" class="tdphoto" valign="top"><p>Profile Photo:</p><br /> <?php echo "<img src=\"images/avatars/{$row['avatar_url']}\"$avatar_url\"  width='280' height='220' align='top' />"; ?></td>
  </tr>
  <tr>
    <td class="tduser"><h1>Acc Name:</h1><?php echo $row['acc_name'];?></td>
    </tr>
  <tr>
    <td class="tduser"><h1>Address:</h1><?php echo $row['address'];?></td>
  </tr>
  <tr>
    <td class="tduser"><h1>Contact:</h1><?php echo $row['contact'];?></td>
  </tr>
  <tr>
    <td class="tduser"><h1>Phone:</h1><?php echo $row['phone'];?></td>
  </tr>
  <tr>
    <td class="tduser" ><h1>Fax:</h1><?php echo $row['fax'];?></td>
     <td class="tduser"><h1>Tourism Route:</h1><?php echo $row['tourism_route'];?></td>
  </tr>
  <tr>
    <td class="tduser"><h1>Email:</h1><?php echo $row['user_email'];?></td>
     <td class="tduser"><h1>Acc Category:</h1><?php echo $row['acc_category'];?></td>
  </tr>
  <tr>
   <td class="tduser"><h1>Website:</h1><?php echo $row['website'];?></td>
    <td class="tduser"><h1>Acc Tariffs:</h1><?php echo $row['acc_tariffs'];?></td>
  </tr>
  <tr>
    <td class="tdbtm" colspan="3"><p>Accommodation Profile</p></td>
  </tr>
  <td></td>
  <tr>
    <td colspan="3"><p><?php echo $row['acc_profile'];?></p></td>
  </tr>
  
  <tr>
    <td class="tdbtm" colspan="3"><p>Accommodation Location</p></td>
  </tr>
  <td></td>
  <tr>
    <td colspan="3"><p><?php echo $row['acc_location'];?></p></td>
  </tr>
  
  <tr>
    <td class="tdbtm" colspan="3"><p>Accommodation Directions</p></td>
  </tr>
  <td></td>
  <tr>
    <td colspan="3"><p><?php echo $row['acc_directions'];?></p></td>
  </tr>
</table>
</td>
</tr>
</table>

  </div>
  <div id="infostrip">
  <p>Information directory to the best accommodation establishments available in the eastern cape's nine tourism routes</p>
</div>

  <!-- start of bottom navigation -->
  <?php include('includes/footer_menu.inc.php'); ?>
  <!-- end of bottom navigation -->

<!-- start footer -->
<?php include('includes/footer.inc.php'); ?>
<!-- end footer -->
</div>

</body>
</html>
sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

hielo. can you provide an example or link to a tutorial.

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

No. I am not updating specfic user details. The link to profile.php will get the current saved details from database of user. User details get displayed when i click link. The problem is that the same user details show when click on link for different users in my user_list.php page. E.G: The profile for user1 gets display for user2 when i click link for profile of user2. The same for others when i click their links to view their profiles. User1 profile keeps getting displayed.

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

I need help with a dynamic link on my web page. This is a site where accommodation establishments register their details and upload a photo.

Here is the problem I have:
I have a page listing all users (user_list.php) where I retrieve details (acc_name, address, photo) of registered users from mysql database. I also have a dynamic link to a page (profile.php) where details of user is listed with a photo.

Everything works fine but when I click the link (first click on link) to the specific users details (profile.php) it displays fine. However, when I go back to my user list (user_list.php) and click the link of another registered user (profile.php) the profile of the previous user are redisplayed. I have reset/cleared all my browsing history but still have the same problem. Below is the code for the link to profile.php in my user_list php page.

<td class='tduser' width=15% align='center' valign='middle'><a href='profile.php?id=".$row['id']."'>".$row['acc_name']."</td>

I am querying the database correctly? Please provide me with a solution to this problem. I am missing something and cannot get around to solving it.
Below find the full code for my user_list.php.

<?php
include 'dbc.php';
include 'includes/title.inc.php';
page_protect();
$member = @$_GET['member'];
/******************** ADD ME TO SHOW USERS AVATAR ****************************/
$img_url_query = mysql_query("select avatar_url from users where id = '$_SESSION[user_id]'");
while($img_url_settings = mysql_fetch_array($img_url_query)) {
$img_url = $img_url_settings['avatar_url'];
}
/*****************************************************************************/

?><!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/default.css" type="text/css" media="screen"/>
<title>Places To Stay In The Eastern Cape<?php if (isset($title)) {echo "&#8212;{$title}";} ?></title>

</head>

<body>
<div id="wrapper">
<div id="topinfobar">
<p><span class="strapline">Magazine Shelf Life: </span>June - August 2010: <span class="style1">3 Months</span></p>
</div>

  <div id="topbanner1"></div>
   <div id="topbanner2"></div>
    <div id="topbanner3"></div>
     <div id="topbanner4"></div>
  
  <div id="cornerbox"></div>
  
  <div id="starlogo"></div>
  
  <div id="tourinfobar">
  <p class="intro">Accommodation Directory to the Eastern Cape's nine tourism routes:</p>
  <p>Tsitsikamma Route  |  Kouga Route  | Sunshine Coast | Frontier Country             
| Friendly N6 <br/> 
Karoo Heartland  | Greater Addo Route | Amatola Mountain Escape | Wildcoast/Cintsa</p>
  
  </div>
  
  <div id="info1"></div>
  
  <div id="topnavbar">
  <div id="topnav">
<?php include('includes/menu.inc.php'); ?>
</div>
  
  </div>
   <div id="register">
  <table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">
   
    <tr>
      <td valign="top"><?php 
/*********************** MYACCOUNT MENU ****************************
This code shows my account menu only to logged in users. 
Copy this code till END and place it in a new html or php where
you want to show myaccount options. This is only visible to logged in users
*******************************************************************/
if (isset($_SESSION['user_id'])) {?>
        <div class="myaccount">
            <p><strong>My Account</strong></p>     
            <a href="myaccount.php">My Account</a><br />
            <a href="register.php">Register Details </a><br />
            <a href="imageupload.php">Upload Picture </a><br />
            <a href="profile.php">User Profile </a><br />
            <a href="mysettings.php">Update Details</a><br />
            <a href="list_users.php">View Users</a><br />
            <a href="logout.php">Logout </a>
           
          </div>
        <?php } 
/*******************************END**************************/
?>
          <p>&nbsp; </p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p></td>
        <td><?php

//check if the starting row variable was passed in the URL or not
if(!isset($_GET['startrow']) or !is_numeric($_GET['startrow'])) {

//we give the value of the starting row to 0 because nothing was found in URL
$startrow = 0;

//otherwise we take the value from the URL
} else {
$startrow = (int)$_GET['startrow'];
}

$result = mysql_query("SELECT * FROM users LIMIT $startrow, 10") or die(mysql_error());
while($row = mysql_fetch_array($result)) { 

echo 
"<table class='tableuser' bgcolor='#FFDB94' cellspacing='0' cellpadding='0' border='0'>
<tr>
<td class='tduser' width='10%' align='center' valign='middle' bgcolor='#FFCC66'><p><img src=\"images/avatars/{$row['avatar_url']}\"$avatar_url\" width='100' border='1' /></p></td>
<td class='tduser' width='20%' align='center' valign='middle'><p>".$row['acc_name']."</p></td>
<td class='tduser'width='20%' align='center' valign='middle'><p>".$row['address']."</p></td>
<td class='tduser' width=15% align='center' valign='middle'><a href='profile.php?id=".$row['id']."'>".$row['acc_name']."</td>
</tr>
</table>";
}
?>
<div id="pagination">
  <?php

//now this is the link
echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.($startrow+10).'"> Next >> </a>';

$prev = $startrow - 10;

//only print a Previous link if a next was clicked
if ($prev >= 0)
echo '<a href="'.$_SERVER['PHP_SELF'].'?startrow='.$prev.'">|  << Previous</a>';
    ?>
</div>
</td>
       
<h3 class="titlehdr">List Users</h3>
      <p>Here you can view all registered users.</p><br />
      </tr>
 </table>
 </div>
  <div id="infostrip">
  <p>Information directory to the best accommodation establishments available in the eastern cape's nine tourism routes</p>
</div>

  <!-- start of bottom navigation -->
  <?php include('includes/footer_menu.inc.php'); ?>
  <!-- end of bottom navigation -->

<!-- start footer -->
<?php include('includes/footer.inc.php'); ?>
<!-- end footer -->
</div>

</body>
</html>
sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi everyone. I am seeking help to display my query result (user list) into several pages. The code below retrieves user details successfully like a picture, accommodation name, address and a clickable link to a profile page related to specific details of user. This page is my users_list.php which displays the details from my mysql database.
The user details gets display but I am trying to limit the display (user details) to 10 rows of data from database in user_list.php The problem I have is that more than 10 rows gets displayed on the page (I actually have 12 rows of data (user details) saved in database). How do I limit details to 10 rows of data per page?
The pagination script I have gets display correctly but when I click through to page 2 on user_list.php the same user details from page 1 also get displayed. I have 12 user details (rows) saved in database. All 12 get displayed on page 1 and 2 in user_list.php
The fields I am retrieving from database are avatar_url, acc_name and address. The picture (avartar_url) are saved to a folder (images/avatars) with the picture url saved to the database.
Can anyone please provide help to solve my problem. My code from users_list.php is below.
Apreciate your help
Thanks.

<?php
include 'dbc.php';
include 'includes/title.inc.php';
include 'includes/ps_pagination.php';

/******************** ADD ME TO SHOW USERS AVATAR ****************************/
$img_url_query = mysql_query("select avatar_url from users where id = '$_SESSION[user_id]'");
while($img_url_settings = mysql_fetch_array($img_url_query)) {
$img_url = $img_url_settings['avatar_url'];
}
/*****************************************************************************/

?><!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/default.css" type="text/css" media="screen"/>
<title>Places To Stay In The Eastern Cape<?php if (isset($title)) {echo "&#8212;{$title}";} ?></title>

</head>

<body>

<h3 class="titlehdr">List Users</h3>
      <p>Here you can view all registered users.</p><br />

<?php
$result = mysql_query("select * from users");
while($row = mysql_fetch_array($result)) { 

echo 
"<table class='tableuser' bgcolor='#FFDB94' cellspacing='0' cellpadding='0' border='0'>
<tr>
<td class='tduser' width='20%' align='center' valign='middle' bgcolor='#FFCC66'><p><img src=\"images/avatars/{$row['avatar_url']}\"$avatar_url\" width='100' border='1' /></p></td>
<td class='tduser' width='20%' align='center' valign='middle'><p>".$row['acc_name']."</p></td>
<td class='tduser'width='20%' align='center' valign='middle'><p>".$row['address']."</p></td>
<td class='tduser' width=20% align='center' valign='middle'><a href='profile.php?id=".$row['id']."'>".$row['acc_name']."</td>
</tr>
</table>";
}
?>
<div id="pagination">
  <?php
	//Connect to mysql db
	$conn = mysql_connect('localhost','admin123','jegg123');
	if(!$conn) die("Failed to connect to database!");
	$status = mysql_select_db('register', $conn);
	if(!$status) die("Failed to select database!");
	$sql = 'SELECT * FROM users';
	
	/*
	 * Create a PS_Pagination object
	 * 
	 * $conn = MySQL connection object
	 * $sql = SQl Query to paginate
	 * 10 = Number of rows per page
	 * 5 = Number of links
	 * "param1=valu1&param2=value2" = You can append your own parameters to paginations links
	 */
	$pager = new PS_Pagination($conn, $sql, 10, 5, 'param1=value1&param2=value2');
	
	/*
	 * Enable debugging if you want o view query errors
	*/
	$pager->setDebug(true);
	
	/*
	 * The paginate() function returns a mysql result set
	 * or false if no rows are returned by the query
	*/
	$rs = $pager->paginate();
	if(!$rs) die(mysql_error());
	while($row = mysql_fetch_assoc($rs)) {
		echo $row['image'],"<br />\n";
	}
	
	//Display the full navigation in one go
	//echo $pager->renderFullNav();
	
	//echo "<br />\n";
	
	/*
	 * Or you can display the individual links for more
	 * control over HTML rendering.
	 * 
	*/
	
	//Display the link to first page: First
	echo $pager->renderFirst();
	
	//Display the link to previous page: <<
	echo $pager->renderPrev();
	
	/*
	 * Display page links: 1 2 3
	 * $prefix = Will be prepended to the page link (optional)
	 * $suffix = Will be appended to the page link (optional)
	 * 
	*/
	echo $pager->renderNav('<span>', '</span>');
	
	//Display the link to next page: >>
	echo $pager->renderNext();
	
	//Display the link to last page: Last
	echo $pager->renderLast();
    ?>
</div>

</body>
</html>
sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Metalix, thanks for your help. The picture gets displayed on page. Thanks to other forum members for their input.

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi everyone.
I in my previous post I said the picture does show from the database. In fact it does not display on the page. Sorry for the confusion.
Thanks.

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi everyone.
I in my previous post I said the picture does show from the database. In fact it does not display on the page. Sorry for the confusion.
Thanks.

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Need help with displaying picture from mysql database. Can anyone provide a basic php script to retrieve picture from database for display in html page. I have database field: avatar_url whichs save filename of picture in database and a folder: images/avatars where the picture get saved saved. This is for jpeg, gif and png files. I have a profile page for users where I want to show their picture next to their related information in a table. The problem is that the picture does show on the page. What am I doing wrong (please see code below)
Appreciate any help.
Thanks

<?php
include 'dbc.php';
page_protect();
$member = @$_GET['member'];
/******************** ADD ME TO SHOW USERS AVATAR ****************************/
$img_url_query = mysql_query("select avatar_url from users where id = '$_SESSION[user_id]'");
while($img_url_settings = mysql_fetch_array($img_url_query)) {
$img_url = $img_url_setting['avatar_url'];
}
/*****************************************************************************/
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>profile search</title>
<link rel="stylesheet" href="css/default.css" type="text/css" media="screen"/>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td width="160" valign="top">
<?php
if(isset($_SESSION['user_id'])) {?>
<div class="myaccount">
<p><strong>My Account</strong></p>
<a href="myaccount.php">My Account</a><br>
  <a href="mysettings.php">Settings</a><br>
    <a href="profile.php">User Profile </a><br>
    <a href="logout.php">Logout </a>
<p>You can add more links here for users</p></div>

<?php }?>

<td width="732" valign="top"><p></p>
<h3 class="titlehdr">Profile of <?php echo $member;?></h3>
<table width="80%" border="0" align="center" cellpadding="10" cellspacing="5" bgcolor="#e5ecf9">
<tr>
<td><form name="form1" method="get" action="profile.php">
User Name:<input name="member" type="text" />
<input type="submit" value="Search" />
</form></td>
</tr>
</table>

<?php
if(isset($_GET['msg'])) {
echo"<div class=\"error\">$_GET[msg]</div>";
}
$query ="SELECT * FROM users WHERE user_name = '$member'";
$result = mysql_query($query);
$num = mysql_numrows($result);
mysql_close();
if($num ==0){
echo"No results to display, please search again.";
}else{
$i=0;
while($i<1){
$acc_name = mysql_result($result,$i,"acc_name");
$user_name = mysql_result($result,$i,"user_name");
$user_email = mysql_result($result,$i,"user_email");
$website = mysql_result($result,$i,"website");
$acc_profile = mysql_result($result,$i,"acc_profile");
$acc_location = mysql_result($result,$i,"acc_location");
$acc_directions = mysql_result($result,$i,"acc_directions");
$date_registered = mysql_result($result,$i,"date_registered"); 
$avatar_url = mysql_result($result,$i,"avatar_url");
echo "<table border RULES=NONE FRAME=BOX WIDTH=\"100%\">
<tr>
<td>User Name:</td><td>$user_name</td>
</tr>
<tr>
<td width = \"50%\">Name:</td><td>$acc_name</td>
</tr>
<tr>
<td>Email Address:</td><td>$user_email</td>
</tr>
<tr>
<td>Website:</td><td>$website</td>
</tr>
<tr>
<td>Acc Profile:</td><td>$acc_profile</td>
</tr>
<tr>
<td>Acc Location:</td><td>$acc_location</td>
</tr>
<tr>
<td>Acc Directions:</td><td>$acc_directions</td>
</tr>
<tr>
<td>Date_registered:</td><td>$date_registered</td>
</tr>
<tr>
<td>Photo:</td><td><img src ='images/avatars/''.$avatar_url.''width='240' 'height='180'> <br /></td>
</tr>

</table><br><br>";
$i++;
}
}
?>
</td>
<td width="196" valign="top"> </td>
</tr>
<tr>
<td colspan="3"></td>
</tr>
</table>
</body>
</html>
sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Can anyone please assist how to retrieve data for dropdown menu from database. I have dropdown menu in mysettings.php of login script v2. The array i am using retrieves the all contents from the database for selected dropdown menu but it does not retrieve the specific saved data selection (dropdown menu) that user registered (register.php) in mysettings.php

Do I use the same mysql_query (rs_mysettings) for the dropdown menu or do I write a new code to query the database for the dropdown menu? If so can anyone please provide solution (query) for the dropdown menu. I am new to php and do not know how to do this.

Basically I want to pull saved data from database in mysettings.php that user saved from selection in dropdown menu at the time they registered their details.

My code for the dropdown menu in register.php

<table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">
<tr>
<td width="147">Acc Category<span class="required">*</span><br />
<select name="acc_category" id="acc_category" class="required">
<option value="" selected></option>
<option value="Bed & Breakfast">Bed & Breakfast</option>
<option value="Guest House">Guest House</option>
<option value="Selfcatering">Selfcatering</option>
<option value="Hotel">Hotel</option>
<option value="Lodge">Lodge</option>
<option value="Backpacker">Backpacker</option>
</select></td>
</tr>
</table>

------------------------------------------------------------------------------
I am using an array as provided by pbu to populate the selectboxes in form (mysettings.php) like so:

<table width="100%" border="0" cellspacing="0" cellpadding="5" class="main">
<tr>
<td width="147">Acc Category<span class="required">*</span><br />
<select name="acc_category" id="acc_category" class="required">
<?php
//Array of accommodation categories for select box
$Categories = array("Bed & Breakfast","Guest House", "Selfcatering", "Hotel","Lodge","Backpacker" );
$dbacc_category = "Guest House"; //Stored in database
foreach ($Categories as $acc_category)
{
if($acc_category == $dbacc_category) {
echo "<option value=\"$acc_category\"SELECTED>$acc_category</option>";
} 
else
{
echo "<option value=\"$acc_category\">$acc_category</option>";
}
}
?>
</select></td>
</tr>
</table>

Any help is apprecieted.

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

thanks everyone for help on how to post code. can you provide solution to retrieve data from database to populate dropdown menu when a user update his details. a simple script will to do this will be appreciated thank you.

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

hi ardav. thanks for responce. can you help with my dropdown menu post? thanks.

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi there,
I am still experiencing problems
to populate the dropdown menu
in my form (mysettings.php) with
the correct contents
from the database.
Herewith is what I have.
<?php
/**********************
MYSETTINGS.PHP***************
***********
This updates user settings and
password
****************************
**********************
**********/
include 'dbc.php';
page_protect();
$rs_settings = mysql_query
("select * from users where id='$
_SESSION[user_id]'");
if(@$_POST ==
'Update')
{
$rs_pwd = mysql_query("select
pwd from users where id='$_
SESSION[user_id]'");
list($old) = mysql_fetch_row($rs_
pwd);
//check for old password in md5
format
if($old == md5($_POST))
{
$newmd5 = md5(mysql_real_
escape_string($_POST
));
mysql_query("update users set
pwd='$newmd5' where id='$_
SESSION[user_id]'");
header("Location: settings.php?
msg=Your new password is
updated");
} else
{
header("Location: settings.php?
msg=Your old password is
invalid");
}
}
if(@$_POST == 'Save')
{
// Filter POST data for harmful
code (sanitize)
foreach($_POST as $key => $
value) {
$data[$key] = filter($value);
}
mysql_query("UPDATE users SET
`acc_name` = '$data[acc_name]
',`contact` = '$data[contact]',
`phone` = '$data[phone]',`fax` = '$
data[fax]',`address` = '$data
[address]',`website` = '$data
[website]',
`acc_profile` = '$data[acc_profile]
',`acc_location` = '$data[acc_
location]',`acc_directions = '$data
[acc_directions]',`acc_category` =
'$data[acc_category]',`acc_
tariffs` = '$data[acc_tariffs]
',`tourism_route` = '$data
[tourism_route]'
WHERE id='$_SESSION[user_id]'
") or die(mysql_error());
header("Location: settings.php?
msg=Profile Sucessfully saved");
}
?>
This is the SQL error I get when
trying to update user
information:
You have an error in your SQL
syntax; check the manual that
corresponds to your MySQL
server version for the right
syntax to use near 'acc_
category` = 'Guest House', `acc_
tariffs` = 'R0 - R350.00', `tourism_
' at line 10
The dropdown menu as in my
registration form (register.php)
<table width="100%" border="0"
cellspacing="0" cellpadding="5"
class="main">
<tr>
<td width="147">Acc
Category<span
class="required">*</span><br />
<select name="acc_category"
id="acc_category"
class="required">
<option value="" selected></
option>
<option value="Bed &
Breakfast">Bed & Breakfast</
option>
<option value="Guest
House">Guest House</option>
<option
value="Selfcatering">Selfcatering<
/option>
<option value="Hotel">Hotel</
option>
<option value="Lodge">Lodge</
option>
<option
value="Backpacker">Backpacker</
option>
</select></td>
</tr>
I have amended the script you
suggested to populate the
selectboxes in form
(mysettings.php) like so:
<table width="100%" border="0"
cellspacing="0" cellpadding="5"
class="main">
<tr>
<td width="147">Acc
Category<span
class="required">*</span><br />
<select name="acc_category"
id="acc_category"
class="required">
<?php
//Array of accommodation
categories for select box
$Categories = array("Bed &
Breakfast","Guest House",
"Selfcatering",
"Hotel","Lodge","Backpacker" );
$dbacc_category = "Guest
House"; //Stored in database
foreach ($Categories as $acc_
category)
{
if($acc_category == $dbacc_
category) {
echo "<option value=\"$acc_
category\"SELECTED>$acc_
category</option>";
}
else
{
echo "<option value=\"$acc_
category\">$acc_category</
option>";
}
}
?>
</select></td>
</tr>
</table>
SQL
Table structure for table `users`
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL
AUTO_INCREMENT,
`md5_id` varchar(200) NOT NULL
DEFAULT '0',
`acc_name` varchar(60) NOT
NULL,
`user_name` varchar(200) NOT
NULL,
`user_email` varchar(220) NOT
NULL,
`pwd` varchar(200) NOT NULL,
`contact` varchar(60) NOT NULL,
`address` text NOT NULL,
`phone` varchar(20) NOT NULL,
`fax` varchar(20) NOT NULL,
`website` text NOT NULL,
`date_registered` date NOT NULL
DEFAULT '0000-00-00',
`acc_profile` text NOT NULL,
`acc_location` text NOT NULL,
`acc_directions` text NOT NULL,
`acc_category` text NOT NULL,
`acc_tariffs` text NOT NULL,
`tourism_route` text NOT NULL,
`users_ip` varchar(200) NOT NULL,
`approved` int(1) NOT NULL
DEFAULT '0',
`activation_code` int(10) NOT
NULL DEFAULT '0',
`banned` int(1) NOT NULL DEFAULT
'0',
PRIMARY KEY (`id`),
UNIQUE KEY `user_email` (`user_
email`),
FULLTEXT KEY `idx_search` (`acc_
name`,`contact`,`user_
email`,`user_name`)
) ENGINE=MyISAM DEFAULT
CHARSET=utf8 AUTO_
INCREMENT=1 ;
Still can't get the dropdown
menu to populate the correct
info from the database. Please
assist me with this problem.
Thanks.

sjeggels
Newbie Poster
22 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
 
© 2013 DaniWeb® LLC
Page rendered in 0.1360 seconds using 2.7MB