Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
Thread Tools Display Modes
Share |
  #1  
Old 04-21-2011, 03:40 PM
kontrol's Avatar
kontrol kontrol is offline
Contributing Member
 
Join Date: 02-10-10
Posts: 223
iTrader: 0 / 0%
php go to detail page

hello, i will be glad to get your assistance on this problem of mine. i am really lost. i want to make some dynamic text links to their detail page which takes its source from users table different from this one and with a recordset filtered with the id equal to the username but my efforts have been so helpless. this are the database columns
(users table: id, first name, last name, username)
(and below is the page code:

PHP Code:
<?php
$host
="localhost"// Host name
$username="root"// Mysql username
$password=""// Mysql password
$db_name="urbansystems"// Database name
$tbl_name="entertain_question"// Table name

// Connect to server and select databse.
mysql_connect("$host""$username""$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// get value of id that sent from address bar
$id=$_GET['id'];

$sql="SELECT * FROM $tbl_name WHERE id='$id'";
$result=mysql_query($sql);

$rows=mysql_fetch_array($result);
?>
            <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
              <tr>
                <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bordercolor="1" bgcolor="#FFFFFF">
                    <tr>
                      <td bgcolor="#F8F7F1"><strong><?php echo ucfirst($rows['topic']); ?></strong></td>
                    </tr>
                    <tr>
                      <td bgcolor="#F8F7F1"><?php echo ucfirst($rows['detail']); ?></td>
                    </tr>
                    <tr>
                      <td bgcolor="#F8F7F1"><strong>Posted by :</strong><?php echo ucfirst($rows['name']); ?></td>
                    </tr>
                </table></td>
              </tr>
            </table>
            <?php
$tbl_name2
="_entertain_answer"// Switch to table "forum_answer"

$sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'";
$result2=mysql_query($sql2);

while(
$rows=mysql_fetch_array($result2)){
?>
            <br />
            <table width="100%" border="0" cellspacing="0" cellpadding="3">
              <tr>
                <td width="17%" rowspan="2" valign="top"><div align="center"><img src="http://www.v7n.com/images/Me..jpg" width="59" height="76" /></div></td>
                <td valign="top"><div align="left"><?php echo ucfirst($rows['a_name']);?></div>
                <div align="left"></div></td>
                <td width="39%" valign="top"><div align="right"><?php echo $rows['a_datetime']; ?></div></td>
              </tr>
              <tr>
                <td colspan="3" valign="top"><?php echo ucfirst($rows['a_answer']); ?></td>
              </tr>
            </table>
            <br />
            <?php
}

$sql3="SELECT view FROM $tbl_name WHERE id='$id'";
$result3=mysql_query($sql3);

$rows=mysql_fetch_array($result3);
$view=$rows['view'];

// if have no counter value set counter = 1
if(empty($view)){
$view=1;
$sql4="INSERT INTO $tbl_name(view) VALUES('$view') WHERE id='$id'";
$result4=mysql_query($sql4);
}

// count more value
$addview=$view+1;
$sql5="update $tbl_name set view='$addview' WHERE id='$id'";
$result5=mysql_query($sql5);

mysql_close();
?>
i only want to make the usernames links to their detail page ie <?php echo ucfirst($rows['topic']); ?> and <?php echo ucfirst($rows['a_name']); ?>

Last edited by ScriptMan; 04-21-2011 at 03:43 PM. Reason: added code tags
 
Reply With Quote

Advertisement

Advertisement

  #2  
Old 04-25-2011, 11:17 PM
nemrod's Avatar
nemrod nemrod is offline
v7n Mentor
 
Join Date: 12-21-10
Location: Sweden
Posts: 463
iTrader: 0 / 0%
Surprised you haven't gotten help yet. Oh well.

If I understood correctly you just want $rows['topic'] and $rows['a_name'] to be links to a page specific for that value? What is it you're having trouble with? It would help if you showed what you've tried or give an example of the result.
 
Reply With Quote
  #3  
Old 04-25-2011, 11:51 PM
kontrol's Avatar
kontrol kontrol is offline
Contributing Member
 
Join Date: 02-10-10
Posts: 223
iTrader: 0 / 0%
on the results page, i have this in the head
PHP Code:
<?php require_once('../Connections/legalfelony.php'); ?><?php
//initialize the session
if (!isset($_SESSION)) {
  
session_start();
}

// ** Logout the current user. **
$logoutAction $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset(
$_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  
$logoutAction .="&"htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  
//to fully log out a visitor we need to clear the session varialbles
  
$_SESSION['MM_Username'] = NULL;
  
$_SESSION['MM_UserGroup'] = NULL;
  
$_SESSION['PrevUrl'] = NULL;
  unset(
$_SESSION['MM_Username']);
  unset(
$_SESSION['MM_UserGroup']);
  unset(
$_SESSION['PrevUrl']);
    
  
$logoutGoTo "../index.php";
  if (
$logoutGoTo) {
    
header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  
session_start();
}
$MM_authorizedUsers "";
$MM_donotCheckaccess "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers$strGroups$UserName$UserGroup) { 
  
// For security, start by assuming the visitor is NOT authorized. 
  
$isValid False

  
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  
if (!empty($UserName)) { 
    
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    
$arrUsers Explode(","$strUsers); 
    
$arrGroups Explode(","$strGroups); 
    if (
in_array($UserName$arrUsers)) { 
      
$isValid true
    } 
    
// Or, you may restrict access to only certain users based on their username. 
    
if (in_array($UserGroup$arrGroups)) { 
      
$isValid true
    } 
    if ((
$strUsers == "") && true) { 
      
$isValid true
    } 
  } 
  return 
$isValid
}

$MM_restrictGoTo "../signin_fail.php";
if (!((isset(
$_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers$_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  
$MM_qsChar "?";
  
$MM_referrer $_SERVER['PHP_SELF'];
  if (
strpos($MM_restrictGoTo"?")) $MM_qsChar "&";
  if (isset(
$QUERY_STRING) && strlen($QUERY_STRING) > 0
  
$MM_referrer .= "?" $QUERY_STRING;
  
$MM_restrictGoTo $MM_restrictGoTo$MM_qsChar "accesscheck=" urlencode($MM_referrer);
  
header("Location: "$MM_restrictGoTo); 
  exit;
}
?><?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$colname_rec_1 "-1";
if (isset(
$_GET['urban'])) {
  
$colname_rec_1 $_GET['urban'];
}
mysql_select_db($database_urbanmayor$urbanmayor);
$query_rec_1 sprintf("SELECT * FROM networking WHERE id = %s"GetSQLValueString($colname_rec_1"int"));
$rec_1 mysql_query($query_rec_1$urbanmayor) or die(mysql_error());
$row_rec_1 mysql_fetch_assoc($rec_1);
$totalRows_rec_1 mysql_num_rows($rec_1);

$colname_home "-1";
if (isset(
$_SESSION['MM_Username'])) {
  
$colname_home $_SESSION['MM_Username'];
}
mysql_select_db($database_urbanmayor$urbanmayor);
$query_home sprintf("SELECT * FROM networking WHERE urban = %s"GetSQLValueString($colname_home"text"));
$home mysql_query($query_home$urbanmayor) or die(mysql_error());
$row_home mysql_fetch_assoc($home);
$totalRows_home mysql_num_rows($home);

$MM_paramName ""

// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// create the list of parameters which should not be maintained
$MM_removeList "&index=";
if (
$MM_paramName != ""$MM_removeList .= "&".strtolower($MM_paramName)."=";
$MM_keepURL="";
$MM_keepForm="";
$MM_keepBoth="";
$MM_keepNone="";
// add the URL parameters to the MM_keepURL string
reset ($_GET);
while (list (
$key$val) = each ($_GET)) {
    
$nextItem "&".strtolower($key)."=";
    if (!
stristr($MM_removeList$nextItem)) {
        
$MM_keepURL .= "&".$key."=".urlencode($val);
    }
}
// add the Form parameters to the MM_keepURL string
if(isset($_POST)){
    
reset ($_POST);
    while (list (
$key$val) = each ($_POST)) {
        
$nextItem "&".strtolower($key)."=";
        if (!
stristr($MM_removeList$nextItem)) {
            
$MM_keepForm .= "&".$key."=".urlencode($val);
        }
    }
}
// create the Form + URL string and remove the intial '&' from each of the strings
$MM_keepBoth $MM_keepURL."&".$MM_keepForm;
if (
strlen($MM_keepBoth) > 0$MM_keepBoth substr($MM_keepBoth1);
if (
strlen($MM_keepURL) > 0)  $MM_keepURL substr($MM_keepURL1);
if (
strlen($MM_keepForm) > 0$MM_keepForm substr($MM_keepForm1);

$MM_paramName ""

// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// create the list of parameters which should not be maintained
$MM_removeList "&index=";
if (
$MM_paramName != ""$MM_removeList .= "&".strtolower($MM_paramName)."=";
$MM_keepURL="";
$MM_keepForm="";
$MM_keepBoth="";
$MM_keepNone="";
// add the URL parameters to the MM_keepURL string
reset ($_GET);
while (list (
$key$val) = each ($_GET)) {
    
$nextItem "&".strtolower($key)."=";
    if (!
stristr($MM_removeList$nextItem)) {
        
$MM_keepURL .= "&".$key."=".urlencode($val);
    }
}
// add the Form parameters to the MM_keepURL string
if(isset($_POST)){
    
reset ($_POST);
    while (list (
$key$val) = each ($_POST)) {
        
$nextItem "&".strtolower($key)."=";
        if (!
stristr($MM_removeList$nextItem)) {
            
$MM_keepForm .= "&".$key."=".urlencode($val);
        }
    }
}
// create the Form + URL string and remove the intial '&' from each of the strings
$MM_keepBoth $MM_keepURL."&".$MM_keepForm;
if (
strlen($MM_keepBoth) > 0$MM_keepBoth substr($MM_keepBoth1);
if (
strlen($MM_keepURL) > 0)  $MM_keepURL substr($MM_keepURL1);
if (
strlen($MM_keepForm) > 0$MM_keepForm substr($MM_keepForm1);

$colname_home "-1";
if (isset(
$_SESSION['MM_Username'])) {
  
$colname_home $_SESSION['MM_Username'];
}
then this the table showing the results
HTML Code:
<table width="100%" height="548" border="0" cellpadding="5"> <tr> <td height="10" colspan="2"><table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF" id="act_content"> <tr> <td bgcolor="#e8eefa"><strong>Basic Information</strong></td> </tr> </table></td> </tr> <tr> <td><strong>Name:</strong></td> <td><?php echo ucfirst($row_rec_1['first']); ?> <?php echo ucfirst($row_rec_1['last']); ?></td> </tr> <tr> <td><strong>Urban name:</strong></td> <td><?php echo ucfirst($row_rec_1['urban']); ?> </td> </tr> <tr> <td><strong>Sex:</strong></td> <td><?php echo ucfirst($row_rec_1['gender']); ?></td> </tr> <tr> <td><strong>Birthday:</strong></td> <td><?php echo $row_rec_1['birthday']; ?> <?php echo ucfirst($row_rec_1['birthmonth']); ?> <?php echo $row_rec_1['birthyear']; ?></td> </tr> <tr> <td><strong>Relationship:</strong></td> <td><?php echo ucfirst($row_rec_1['relationship']); ?></td> </tr> <tr> <td><strong>Looking for:</strong></td> <td><?php echo ucfirst($row_rec_1['looking_for']); ?><strong> in terms of</strong> <?php echo $row_rec_1['in_terms']; ?></td> </tr> <tr> <td><strong>Religion:</strong></td> <td><?php echo ucfirst($row_rec_1['religion']); ?></td> </tr> <tr> <td><strong>Interest:</strong></td> <td><?php echo ucfirst($row_rec_1['interests']); ?></td> </tr> <tr> <td><strong>Biography:</strong></td> <td><?php echo ucfirst($row_rec_1['biography']); ?></td> </tr> <tr> <td height="10" colspan="2"><table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF" id="act_content"> <tr> <td bgcolor="#e8eefa"><strong>Contact information</strong></td> </tr> </table></td> </tr> <tr> <td><strong>Email:</strong></td> <td><?php echo strtolower($row_rec_1['mail']); ?></td> </tr> <tr> <td><strong>Mobile:</strong></td> <td><?php echo $row_rec_1['mobile']; ?></td> </tr> <tr> <td><strong>Telephone:</strong></td> <td><?php echo $row_rec_1['telephone']; ?></td> </tr> <tr> <td><strong>Address:</strong></td> <td><?php echo ucfirst($row_rec_1['address']); ?></td> </tr> <tr> <td colspan="2"><table width="100%" border="0" cellpadding="5" cellspacing="0" bgcolor="#FFFFFF" id="act_content"> <tr> <td bgcolor="#e8eefa"><strong>Work and education</strong></td> </tr> </table></td> </tr> <tr> <td><strong>Education:</strong></td> <td><?php echo ucwords($row_rec_1['education']); ?> </td> </tr> <tr> <td><strong>High school:</strong></td> <td><?php echo ucwords($row_rec_1['high_school']); ?> </td> </tr> <tr> <td><strong>College:</strong></td> <td><?php echo ucwords($row_rec_1['college']); ?> </td> </tr> <tr> <td><strong>Economic activity:</strong></td> <td><?php echo ucfirst($row_rec_1['economic_act']); ?></td> </tr> <tr> <td><strong>Company:</strong></td> <td><?php echo ucwords($row_rec_1['organisation']); ?> </td> </tr> </table>

Last edited by snakeair; 04-26-2011 at 08:58 AM.
 
Reply With Quote
  #4  
Old 04-26-2011, 04:38 AM
nemrod's Avatar
nemrod nemrod is offline
v7n Mentor
 
Join Date: 12-21-10
Location: Sweden
Posts: 463
iTrader: 0 / 0%
Okay, but could you explain what the expected result is? Give an example. If you want a link in a specific place, where do you want it and where does it lead? I'm afraid I'm still not quite clear on what it is you're trying to achieve.

PS. next time it would help if you could use [ php]php code here[ /php] (without the spaces)
 
Reply With Quote
  #5  
Old 04-26-2011, 04:56 AM
kontrol's Avatar
kontrol kontrol is offline
Contributing Member
 
Join Date: 02-10-10
Posts: 223
iTrader: 0 / 0%
the link <?php echo ucfirst($rows['a_name']); ?> is a loop and any one who makes a post gets his name shown. Now i want the displayed name be a link to their profile page that is view_details.php
 
Reply With Quote
  #6  
Old 04-26-2011, 04:57 AM
nemrod's Avatar
nemrod nemrod is offline
v7n Mentor
 
Join Date: 12-21-10
Location: Sweden
Posts: 463
iTrader: 0 / 0%
Quote:
Originally Posted by kontrol View Post
the link <?php echo ucfirst($rows['a_name']); ?> is a loop and any one who makes a post gets his name shown. Now i want the displayed name be a link to their profile page that is view_details.php
Okay. What's the querystring you use on view_details.php?
 
Reply With Quote
  #7  
Old 04-26-2011, 05:04 AM
kontrol's Avatar
kontrol kontrol is offline
Contributing Member
 
Join Date: 02-10-10
Posts: 223
iTrader: 0 / 0%
PHP Code:
$colname_rec_1 "-1";
if (isset(
$_GET['urban'])) {
$colname_rec_1 $_GET['urban'];
}
mysql_select_db($database_urbanmayor$urbanmayor);
$query_rec_1 sprintf("SELECT * FROM networking WHERE id = %s"GetSQLValueString($colname_rec_1"int"));
$rec_1 mysql_query($query_rec_1$urbanmayor) or die(mysql_error());
$row_rec_1 mysql_fetch_assoc($rec_1);
$totalRows_rec_1 mysql_num_rows($rec_1); 

Last edited by snakeair; 04-26-2011 at 08:59 AM.
 
Reply With Quote
  #8  
Old 04-26-2011, 06:20 AM
nemrod's Avatar
nemrod nemrod is offline
v7n Mentor
 
Join Date: 12-21-10
Location: Sweden
Posts: 463
iTrader: 0 / 0%
So you do you want $rows['a_name'] to be a link to "view_details.php?urban=id"?
If so then you just have to replace
PHP Code:
<?php echo ucfirst($rows['a_name']); ?>
with
PHP Code:
<?php echo '<a href="view_details.php?urban=' $rows['id'] . '">' ucfirst($rows['a_name']) . '</a>'?>
 
Reply With Quote
  #9  
Old 04-26-2011, 06:49 AM
kontrol's Avatar
kontrol kontrol is offline
Contributing Member
 
Join Date: 02-10-10
Posts: 223
iTrader: 0 / 0%
ok. thank you for your kindness. i am going to work on it and i will give you feed back. thank you once more
 
Reply With Quote
  #10  
Old 04-26-2011, 08:20 AM
kontrol's Avatar
kontrol kontrol is offline
Contributing Member
 
Join Date: 02-10-10
Posts: 223
iTrader: 0 / 0%
It displays this with the link working but nothing on the view_details.php

Notice: Undefined index: id in C:\xampp\htdocs\mayor\forum\general\view_topic.php on line 335

i think it is the way i explained things. view_details.php is connected to a different db table and the page i was dealing with is connected to the forum_answer table.

i coded it this way:
PHP Code:
    <?php
$tbl_name2
="forum_answer"// Switch to table "forum_answer"

$sql2="SELECT * FROM $tbl_name2 WHERE question_id='$id'";
$result2=mysql_query($sql2);

while(
$rows=mysql_fetch_array($result2)){
?>
            <br />
            <table width="100%" border="0" cellspacing="0" cellpadding="3">
              <tr>
                <td width="17%" rowspan="2" valign="top"><div align="center"><img src="http://www.v7n.com/images/Me..jpg" width="59" height="76" /></div></td>
                <td valign="top"><div align="left"><strong></strong><?php echo '<a href="http://www.v7n.com/home/view_details.php?urban=' $rows['id'] . '">' ucfirst($rows['a_name']) . '</a>'?></div>
                <div align="left"></div></td>
                <td width="39%" valign="top"><div align="right"><?php echo $rows['a_datetime']; ?></div></td>
              </tr>
              <tr>
                <td colspan="3" valign="top"><?php echo ucfirst($rows['a_answer']); ?></td>
              </tr>
            </table>
            <br />
            <?php
}
there is a column in the forum_answer table called urban_id, it stores the id's is the user who posts in to the forum_answer. will be required in this quest?

Last edited by snakeair; 04-26-2011 at 09:00 AM.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
passing search results to detail page kontrol Coding Forum 1 02-27-2011 11:19 AM
Detail Page Statistics Belinda Web Directory Issues 7 08-28-2010 09:29 PM
Please help me on detail moonheart Google Forum 9 11-12-2009 11:42 PM
More Directory Detail arius Web Directory Issues 3 08-05-2004 03:21 AM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 01:35 PM.
Powered by vBulletin
Copyright 2000-2014 Jelsoft Enterprises Limited.
Copyright © 2003 - 2018 VIX-WomensForum LLC