Posts by Inkeliz • 20,671 points
671 posts
-
3
votes1
answer509
viewsA: Friends system in PHP and SQL
There are several ways, with different levels of performance and ease. SELECT utilizador.* FROM utilizador WHERE id IN (SELECT user_2_id FROM amigos WHERE user_1_id = '6'); In this case user_2_id…
-
1
votes3
answers1264
viewsA: Redirect user according to login name
There is no code published I will say a generic: <? if($lucas){ header('location: https://example.com/lucas'); } if($daniel){ header('location: https://example.com/daniel'); } ?> Remarks: You…
-
2
votes1
answer83
viewsA: Array ? How to resolve
By logic the names are with a pattern, so rename some getting like this: Create a "separate" file and just change true and false to check how it would work, it’s easier. <?php $S =…
-
1
votes2
answers1139
viewsA: PHP - How to fill a field using Curl?
This is very simple. First the file structure is, according to Voce, ("I have a list with name and email below each other"): nome [email protected] Then loop the file: // Abre o arquivo $arquivo =…
-
2
votes2
answers1363
viewsA: Submit from several sources with AJAX, one at a time
If there are multiple formats, with same id: Form + Button Change this: <form method="post" enctype="multipart/form-data" action="#" id="form1" class="form"> For this (assuming it should be in…
-
1
votes1
answer231
viewsA: Implement Follow/Stop Following functionality
I think there’s a much easier way to solve the problem. Solution 1: Replace the line: if(in_array($idatual, $consulta3)){ For: if(in_array($idatual, $consulta3['idfollowed'])){ Idea: in_array should…
-
1
votes2
answers201
views -
3
votes4
answers632
viewsA: How to execute two querys in a statement?
Would be simple. Try: SELECT ( SELECT COUNT(*) FROM tabela ) AS TR, ( SELECT COUNT(*) FROM tabela WHERE valor < 1 ) AS TRCVM1 This will return 2 TR results and TRCVM1. TR = SELECT COUNT(*) FROM…
-
1
votes1
answer48
viewsA: Any explanation for this SQL?
You can unite all MODIFY: ALTER TABLE imovel MODIFY (ENDERECO VARCHAR(150), BAIRRO VARCHAR(150) ); NOTE: I don’t know if it is compatible with Mysql above! But, you can also remove the "COLUMN"…
-
0
votes2
answers2335
viewsA: PHP with HTML - Place an array inside a select html
You can use this: <? $inicio = 1; $ultimo = 5; //esse valor vem do banco. $arr = range($inicio, $ultimo); print_r($arr); ?> <select name="n"> <? foreach($arr as $n){ ?> <option…
-
1
votes1
answer102
viewsA: How to concatenate SQL statements?
According to Mysql documentation (http://dev.mysql.com/doc/refman/5.1/en/alter-table.html), you cannot ADD and DROP in the same function, however you can split all DROP and ADD. Basically the…
-
1
votes1
answer905
viewsA: How to create columns dynamically with SQL?
Try to do the following: $pdo = new PDO('mysql:host=host;dbname=banco', $userdB, $passdB); foreach($res as $item){ $sql .= $item['field']." VARCHAR(300),"; // O valor de $SQL sera "item…
-
0
votes2
answers474
viewsA: Convert an entire number from the database into an Array
You could exemplify with the very code you are using, it would make it much easier, for me got confused what you want, if you could say how the situation is now and how you want, it would be much…
-
1
votes2
answers115
viewsA: How can I return data that is inside arrays?
Just make a loop, for example: Using FOR for($i = 0; $i < count($res); $i++){ echo $res[$i]['field']; } Using FOREACH foreach($res as $field){ echo $field['field']; } In both ways, it will result…
-
2
votes1
answer252
viewsA: Contact form does not work
The problem is in the XAMP configuration, I suggest testing on a server outside the localhost, if possible. But if you want to keep it there you have to change the settings: PHP.INI: C: xampp…
-
6
votes1
answer2054
viewsA: online users and time spent on the site
One of the ways is to keep updated in the database the record of the last date that the user accessed the website and keep updated. In this example I will update the registration every 10 seconds.…
-
2
votes1
answer97
viewsA: Get data according to Mysql date
If you have a 'column' with the type DATE, may use the following: SELECT * FROM table WHERE coluna > '2011-03-01' AND coluna < '2014-12-25' If 'column' is in DATETIME may use the following:…
-
2
votes3
answers2044
viewsA: Problems with session_start()
This is due to the cookie that saves the session, usually with PHPSESSION name, is restricted to only one subdomain. Check, in an old F12 if in the sending headers on the restricted page is…
-
2
votes2
answers204
viewsA: Scan source code and find wikipedia url
Apparently you want to get the Wikipedia link through a correct Google search? Well, I just created and tested a solution for you, maybe not one of the best, however it works! :D <? $TermoDeBusca…
-
3
votes2
answers749
viewsA: Capture div by class
Change the USER_AGENT. Alter: curl_setopt($ch, CURLOPT_USERAGENT, "Opera/9.80 (J2ME/MIDP; Opera Mini/4.2.14912/870; U; id) Presto/2.4.15"); To: curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0…
-
1
votes5
answers786
viewsA: Can I make a Javascript call through PHP?
You can use: <? if($a and $b){ //se A e B ?> <script> alert('hello');//javascript </script> <? } //fim se ?> But, Alert (or any command) will be issued on the client side,…