Jump to content
php.lv forumi

Linka izveide PHP


kalabox

Recommended Posts

..Joprojām mokos ar Linka izveidi/ pārveidi......Esmu nupat drusku pamācījies php pamatlietas, bet joprojām nesaprotu, kā to uzkombinēt, bet tam taču jābūt kaut kam loti vienkāršam....Lūgums palīdzēt, ja kāds var....

 

1.No

registrācijas

formas tiek iegūts

links -->items

(atbilstoši katram registrētam item)

2. ( ir arī MySQL izveidota attiecīga

aile priekš linka --> no registracijas

)

3. Pie katra atbilstošā item jāpieliek klāt atbilstošais links no itema registracijas. (external link). - Kā to uzkonstruēt?!

 

Pašlaik to vietu aizņem:

 

$link = array();

$url="

 

$link['LINK']=$url;

$link['TEXT']=jr_gettext('');

 

$bookinglink[] = $link;

p.s. Vecais links kas jānomaina bija konstruēts:

$url=SITEPAGE_URL."&task=dobooking&selectedProperty=$property_uid";

-bet tas man tagad neder......tas gāja uz booking form pēc $property_uid

Jauta kāds paziņa! :)

Link to comment
Share on other sites

izveidot php linku lai

ID1---> link1 ID2--->Link2 utt. (ID - registretais items(property) Link - registretais Links registrejot ipašumu);

 

Lai lapā ar īpašumu 1 ieliktu Linku 1 , lapā ar īpašumu 2 ieliktu linku ar īpašumu 2 utt.

Link to comment
Share on other sites

Izmanto šo Brainfuck bibliotēku:

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++
..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

 

Lai integrētu iekš PHP, vari izmantot šo PHP Brainfuck interpretātoru:

<?php
$code = '';
if ($_POST['submit']) {
//Now that we are started, we make a html tag that should only be used if there is stuff like this.
echo '<div class="verbose">';
$pointer = 0; //The pointer of our application
$array = array(); //The array the includes all the elements' values.
$code = $_POST['code']; //The code
$vertype = $_POST['verbose']; //The verbose type
if ($vertype < 3) //In case of less verbose, there is no need for this link.
 echo '<a href="#bookmark" title="Goto output">Goto output...</a><br /><br />';
$len = strlen($code); //Let's get the length of the code.
$startsub = 0; //Instead of displaying each time an element goes up or down, this will put them all together for less verbose.
$startcnt = 0; //Same as above, just subtract
$bcnt = 0; //The amount of borders or loops ( [ ] )
$whilec = 0; //A system to check if there is loop going...
$crinput = 0; //The position in the input.
$input = $_POST['input']; //The input.
for ($q = 0; $q < $len; $q++) { //This system will check to make sure there is the same amount of [ and ].
 if ($code[$q] == '[') {
  $bcnt++;
 } elseif ($code[$q] == ']') {
  if ($bcnt == 0) { //In case a ] is encountered before any [, there is something wrong, therefore terminate.
echo 'Error. A \']\' was found before any \'[\', terminating interpreter<br /><br />';
$q = $len * 2;
$bcnt = 3;
  }
  $bcnt--;
 }
}
if ($bcnt == 0) { //Since we have a good result in our test, let's interpret the application.
 for ($i = 0; $i < $len; $i++) { //This is our master for loop, that will go on, untill we don't have any more code.
  if ($code[$i] == '+') { //In case we encounter a '+' we want to add one to our current element.
if ($startsub > 0) { //This is to see if there has been doing some subtracting before, and therefore it should be displayed to user. This is seen in every sign we check, though not '-' itself. And '+' as the same system, just so I don't have to repeat myself over again.
	print_subtract($startsub, $pointer);
	$startsub = 0;
}
$array[$pointer]++; //Add one.
if ($vertype < 2) { //If we have a lot of verbose, we want to display that we added one.
	echo 'Added 1 to element '.$pointer."<br />\nElement ".$pointer.'\'s current value: '.$array[$pointer].'<br /><br />'."\n";
} elseif ($vertype == 2) { //This is the system that will only display a message when we stopped adding ( in case of something like: '++++++' )
	$startcnt++;
}
  } elseif ($code[$i] == '-') { //Same as above, just subtract
if ($startcnt > 0) {
	print_adding($startcnt, $pointer);
	$startcnt = 0;
}
$array[$pointer]--;
if ($vertype < 2) {
	echo 'Subtracted 1 from element '.$pointer."<br />\nElement ".$pointer.'\'s current value: '.$array[$pointer].'<br /><br />'."\n";
} elseif ($vertype == 2) {
	$startsub++;
}
  } elseif ($code[$i] == '<') { //Let's see if we can move the system to the left.
if ($startcnt > 0) {
	print_adding($startcnt, $pointer);
	$startcnt = 0;
} elseif ($startsub > 0) {
	print_subtract($startsub, $pointer);
	$startsub = 0;
}
if ($pointer == 0) { //In case we are at the left most element, we cannot move further.
	echo 'We are pointing at element 0, cannot go further left.<br /><br />';
	$j = $i;
	while ($whilec>0) { //In case we are in a while loop, we want to stop the while loop, as this could mean it will go infinity now, so we look for the ] that will let us out of here.
 	$j++;
 	if ($code[$j] == '[') {
  	$whilec++;
 	} elseif ($code[$j] == ']') {
  	$whilec--;
 	}
	}
	if ($vertype < 3) //The HTML will fuck up if we don't end the <div> now.
 	echo '</div>Ending while loop for security reasons, ince the pointer tried going to an element that doesn\'t exist!<br />';
	$i = $j;
} else { //In case everything is alright, do as normal...
	$old = $pointer; //That's just for the verbose.
	$pointer--; //Go down.
	if (!$array[$pointer]) { $array[$pointer] = 0; } //If the element hasn't go any value, set it to 0. Though, it should have, cause we will always come from the left.
 	if ($vertype < 3) //The verbose.
  	echo 'Going to element '.$pointer.' from element '.$old.'<br />Element '.$pointer.'\'s value: '.$array[$pointer].'<br /><br />';
}
  } elseif ($code[$i] == '>') { //Now turning the other way.
if ($startcnt > 0) {
	print_adding($startcnt, $pointer);
	$startcnt = 0;
} elseif ($startsub > 0) {
	print_subtract($startsub, $pointer);
	$startsub = 0;
}
$old = $pointer;
$pointer++;
$maxpointer = ($maxpointer<$pointer)?$pointer:$maxpointer; //In case we haven't been here before, we will use this to check how many elements we have touched.
if (!$array[$pointer]) { $array[$pointer] = 0; } //Setting the value to 0, if null.
	if ($vertype < 3)
 	echo 'Going to element '.$pointer.' from element '.$old.'<br />Element '.$pointer.'\'s value: '.$array[$pointer].'<br /><br />';
  } elseif ($code[$i] == '[') { //In case we stumble over a start of a loop.
if ($startcnt > 0) {
	print_adding($startcnt, $pointer);
	$startcnt = 0;
} elseif ($startsub > 0) {
	print_subtract($startsub, $pointer);
	$startsub = 0;
}
if ($array[$pointer] != 0) { //If our current element ain't 0, the loop can start.
	if ($vertype < 3)
 	echo 'Starting while loop ( until current element is 0 )...<br /><div>';
	$whilec++; //Those adding the fact that it's a loop.
} else { //If not, then we have to find the end of it.
	if ($vertype < 4)
 	echo 'Skipping while loop, since current element is 0<br />';
	$j = $i;
	$cnt = 1;
	while ($cnt>0) { //With this while system...
 	$j++;
 	if ($code[$j] == '[') {
  	$cnt++;
 	} elseif ($code[$j] == ']') {
  	$cnt--;
 	}
	}
	$i = $j;
}
  } elseif ($code[$i] == ']') { //If it's an end loop.
if ($startcnt > 0) {
	print_adding($startcnt, $pointer);
	$startcnt = 0;
} elseif ($startsub > 0) {
	print_subtract($startsub, $pointer);
	$startsub = 0;
}
if ($array[$pointer] != 0) { //Okay, we have to try again.
	$j = $i;
	$cnt = 1;
	while($cnt > 0) { //Finding the start of the system.
 	$j--;
 	if ($code[$j] == '[') {
  	$cnt--;
 	} elseif ($code[$j] == ']') {
  	$cnt++;
 	}
	}
	$i = $j;
} elseif ($vertype < 3) { //If not, end the loop.
	echo '</div>Ending while loop...<br />';
	$whilec--;
}
  } elseif ($code[$i] == '.') { //Our output system.
if ($startcnt > 0) {
	print_adding($startcnt, $pointer);
	$startcnt = 0;
} elseif ($startsub > 0) {
	print_subtract($startsub, $pointer);
	$startsub = 0;
}
if ($array[$pointer] < 32) { //If the character ain't a valid ASCII character ( below 32 ), we'll have to notice about that.
	if (($array[$pointer] == 0) or ($array[$pointer] == 10)) { //However, if it's 0 or 10, then it's a breakline ( notice: 0 acts like a breakline in Brainfuck )
 	if ($vertype < 2)
  	echo 'This is a break line.<br /><br />';
 	$endstring .= '<br />'; //Add to the final output.
	} else { //Or just do an error if it's not 0 or 10.
 	if ($vertype < 4)
  	echo 'Element '.$pointer.'\'s ASCII value is a not valid ASCII value.<br /><br />';
	}
} elseif ($array[$pointer] == 32) { //If it's 32, it's a space, and we'll treat that a bit different.
	if ($vertype < 3)
 	echo 'Printing element '.$pointer.' in ASCII: [space]<br /><br />';
	$endstring .= ' '; //Add to the final output.
} elseif ($array[$pointer] > 255) { //Should it be higher than 255 ( not a valid ASCII number either, then return an error.
	if ($vertype < 4)
 	echo 'The value of element '.$pointer.' is higher than 255, and thus a valid ASCII value.<br /><br />';
} else { //If all of that ain't true, then we got ourselve one we can work with.
	if ($vertype < 3)
 	echo 'Printing element '.$pointer.' in ASCII: '.chr($array[$pointer]).'<br /><br />';
	$endstring .= chr($array[$pointer]); //Add to the output.
}
  } elseif ($code[$i] == ',') { //If we stumble over an input system, then we'll do this...
if ($startcnt > 0) {
	print_adding($startcnt, $pointer);
	$startcnt = 0;
} elseif ($startsub > 0) {
	print_subtract($startsub, $pointer);
	$startsub = 0;
}
if ($input[$crinput]) { //First we check if there is an input for the current position in the complete input.
	$array[$pointer] = ord($input[$crinput]); //Then we inserts the characters value.
	if ($vertype < 3) //The verbose...
 	echo 'Inserted ASCII character ( '.$input[$crinput].' ) value ( '.ord($input[$crinput]).' ) into element '.$pointer.'<br />Element '.$pointer.'\'s current value: '.$array[$pointer].'<br /><br />';
	$crinput++; //And we move our system up one.
} else { //If there isn't anything in the system right now, we have to notice the user, in case it's an error.
	if ($array[$pointer] != 10) { //If the current one ain't 10, we'll have to try that.
 	$array[$pointer] = 10; //Since 10 acts like a new line, we'll use that, some brainfuck applications assumes that 10 is the value to go after and would end a loop when 10 is the value ( with some subtracting of course ).
 	if ($vertype < 4)
  	echo 'There was found no data to insert at element '.$pointer.'. Acts like a newline...<br />Please insert more data in your input.<br />';
	} else { //If we have tried 10, and that didn't work, then we set the element to 0, cause the creater haven't thought of using a system that would subtract if 10 is happening.
 	$array[$pointer] = 0;
	}
}
  } else { //If our character should be ignored...
if ($vertype < 2)
	echo 'Character \''.$code[$i].'\' unknown... skipping...<br />'."\n";
  }
 }
 if ($startcnt > 0) { //If our applications ends with an adding going on, let's finish it up.
  print_adding($startcnt, $pointer);
 } elseif ($startsub > 0) {
  print_subtract($startsub, $pointer);
 }
 echo '<br /><br />'; //Do some line breaking...
 $arraystring = ''; //Set our arraystring
 $pointerstring = ''; //And pointerstring.
 for ($i = 0; $i <= $maxpointer; $i++) { //Let $i goto the highest element we managed in our application.
  $nown = (!$array[$i])?'0':$array[$i]; //If the value of it is null, make it to 0.
  $space = ($array[$i]<100)?(($array[$i]<10)?'   ':'  '):' '; //To make it look good, add the amount of spaces need to the value.
  $arraystring .= '['.$nown.']'.$space; //Add to our complete string.
  if ($i == $pointer) { //Should $i be at where the pointer ended, then add some spaces so the user can see it point.
for ($j = 0; $j <= ($pointer * 6); $j += 2) {
	$pointerstring .= '  ';
}
$pointerstring .= '^';
  }
 }
 echo '<a name="bookmark"></a>'.$arraystring.'</a><br />'.$pointerstring; //The bookmark link is at the top with verbose, so let's make the link's direction here. And then add the arraystring and the pointerstring.
 echo '<br /><br />Complete output:<br />'.$endstring; //And at last, the output.
} else { //In case our application failed, we have to tell the user that we couldn't start the application.
 echo 'Cannot start, there is no harmony between [\'s and ]\'s, in order for the application to work, there must be the same amount of [\'s and ]\'s';
}
echo '</div>'; //And end...
}
function print_adding($startcnt, $pointer) //This function is the function that is seen being used so many times, cause it will echo that the value ($startcnt) has been added to the element $pointer.
{
global $array; //Let's grab the array.
echo 'Added '.$startcnt.' to element '.$pointer."<br />\nElement ".$pointer.'\'s current value: '.$array[$pointer].'<br /><br />'."\n"; //Let's tell the user.
}
function print_subtract($startsub, $pointer) //Same above, just subtract.
{
global $array;
echo 'Subtracted '.$startsub.' from element '.$pointer."<br />\nElement ".$pointer.'\'s current value: '.$array[$pointer].'<br /><br />'."\n";
}
function print_output($vbmsg, $pointer) //The output verboser system, not really that much need for commenting...
{
global $array, $endstring;
if ($array[$pointer] < 32) {
 if (($array[$pointer] == 0) or ($array[$pointer] == 10)) {
  if ($vbmsg < 2)
return 'This is a break line.<br /><br />';
  $endstring .= '<br />';
 } else {
  if ($vbmsg < 4)
return 'Element '.$pointer.'\'s ASCII value is a not valid ASCII value.<br /><br />';
 }
} elseif ($array[$pointer] == 32) {
 if ($vbmsg < 3)
  return 'Printing element '.$pointer.' in ASCII: [space]<br /><br />';
 $endstring .= ' ';
} elseif ($array[$pointer] > 255) {
 if ($vbmsg < 4)
  return 'The value of element '.$pointer.' is higher than 255, and thus a valid ASCII value.<br /><br />';
} else {
 if ($vbmsg < 3)
  return 'Printing element '.$pointer.' in ASCII: '.chr($array[$pointer]).'<br /><br />';
 $endstring .= chr($array[$pointer]);
}
}//In fact, I don't even think it's used... Heh.
?>

Link to comment
Share on other sites

ar šo te cīnos....

 

http://cheaphostelin...ypography/rese…

 

- tajā linkā zem 'book a resource' - vajag ieprogrammēt ārēju linku, uz īpašuma adresi ()nevis iekšējo booking linku)

 

man jau liekas, varbūt var kaut kā ar foreach () vai vēl kaut kā.......un lai tas links no registracijas formas aiziet uz to formulu.....

ar if , tad tur būtu jau iepriekš jāzina kas tiek registrēts un aiznemtu puslapu....

Link to comment
Share on other sites

  • 4 months later...

Sveiki visiem,

 

Šis bija patiesībā mans jautājums, vārds vārdā nokopēts ko es tiku rakstījis draugiem domubiedru grupā - kāds bez jebkādas saskaņošanas ar mani kopējis te, par ko esmu ljoti neapmierināts, nejauši uzdūros caur googli....

 

Jautājumu es savulaik jau tiku pats atrisinājis :

 

 

$query= "SELECT property_link FROM jomla_propertys WHERE propertys_uid=$property_uid";

$query_run = mysql_query ($query);

 

$url= mysql_result ($query_run, 0, 'property_link');

 

 

- Bet - kas attiecas uz "nesaprata jautājumu"

- nu, man jau liekas viss it kā bija pateikts - Cilvēki (klienti) registrē Items, aizpildot registrāciju, un katrs items iegūst automātisku php iekšējo url (uz kasi , piemēram) - jautājums bija kā šādu url aizstāt ar ārēju URL, kurš saglabāts mySQL vienā tabulā ar Item.....

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...