Jump to content

Help: Linking


shank888

Recommended Posts

Hey all.

 

This is my first post and hopefulyl not the last. as well I hope to be helping more then receiving help.

 

anyways here is my problem:

 

I am building my website in a single PHP file.

 

$action = $_GET['action'];

$filename = 'index.php';

$host = "myipaddres/index.php";

 

if($action == 'index2')

{

echo "<td width='50%'>

<a href='$host?action=cat_id=$cat_id&user_id=$user_id'>

            </td>";

}

 

// Okay so I mate this short little acton script where if someone links the link above it'll show the next page.

 

if($action == 'cat_id=$cat_id&forum_id=$forum_id') {

echo "sucess!";

 

 

Would someone be able to tell me why this isn't working. like I know it's a problem with the $action varbiable but how would I sucessfully link the to. oh btw I have a working connect to MySQL script running off of this. it's just little code snipplets. any help would be appretiated.

 

 

Link to comment
https://forums.phpfreaks.com/topic/39403-help-linking/
Share on other sites

Change this line:

 

 echo "<td width='50%'>
      <a href='$host?action=cat_id=$cat_id&user_id=$user_id'>   
             </td>";

 

to

 

 echo "<td width='50%'>
      <a href='$host?action=cat_id=".urlencode("{$cat_id}&")."user_id=$user_id'>   
             </td>";

 

 

Hmm that didn't work.

I don't really like giving out my whole code over the net so I made a bigger snippet so it'll be easier to see whats going on

 

 

<?php

// Global Variables ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$action = $_GET['action']; // Determines what page is being displayed
$filename = 'index.php'; // Current name of file, eg: index.php
$host = "NULL/index.php";
$username_sql = "NULL";
$password_sql = "NULL";
//MySQl Connect		
$conn=mysql_connect(localhost,$username_sql,$password_sql)
or die(mysql_error());
@mysql_select_db("NULL",$conn) or die(mysql_error());

<table cellspacing='1' width='780'>
			<tr>
$query3="SELECT * FROM `NULL` WHERE forum_cat_id = $cat_id";
			$result2=mysql_query($query3,$conn);
			while ($row3=@mysql_fetch_array($result2))
				{
					@extract($row3);
					echo"

						<td width='50%'>
<a href='$host?action=cat_id=".urlencode("{$cat_id}&")."user_id=$user_id'>  							
						<b>$user_name</b><br /></a>
							$user_desc
						</td>
			}
		echo"</table>";
	}
}
if($action == 'cat_id=$cat_id&user_id=$user_id') {


	$query4="SELECT * FROM `NULL` WHERE NULL_BLAH_id = $user_id";
			$result3= mysql_query($query4,$conn);
			while ($row4=@mysql_fetch_array($result3))
				{
					@extract($row4);

if (@mysql_num_rows($row4) < 1) {
//If no topics display this error
$display_block = "<p><i>There are currently no users</i></p>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/39403-help-linking/#findComment-190148
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

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