Hello,
I did this search engine just for one table:
<?php
$button = $_GET ['submit'];
$search = $_GET ['search'];
if(strlen($search)<=1)
echo "Search term too short";
else{
echo "You searched for <b>$search</b> <hr size='1'></br>";
mysql_connect("localhost","root","");
mysql_select_db("rmworshipers");
$search_exploded = explode (" ", $search);
$x=1;
foreach($search_exploded as $search_each)
{
$x++;
}
$constructs ="SELECT * FROM events WHERE event_name LIKE '%$search_each%'";
$run = mysql_query($constructs) or die(mysql_error());
$foundnum = mysql_num_rows($run);
if ($foundnum==0)
echo "Sorry, there are no matching result for <b>$search</b>.";
else
{
echo "$foundnum results found !<p>";
$per_page = 10;
if(isset($_GET['start'])){
$start = $_GET['start'];
}
$max_pages = ceil($foundnum / $per_page);
if(!isset($_GET['start'])){
$start=0;
}
$getquery = mysql_query("SELECT * FROM events WHERE event_name LIKE '%$search_each%' LIMIT $start, $per_page");
$runrows = mysql_fetch_assoc($getquery);
do{
$id = $runrows ['event_id'];
$nome = $runrows ['event_name'];
echo "$id - <a href='$id'>$nome</a><p>";
}while($runrows = mysql_fetch_assoc($getquery));
//Pagination Starts
$prev = $start - $per_page;
$next = $start + $per_page;
$adjacents = 3;
$last = $max_pages - 1;
if($max_pages > 1)
{
//previous button
if (!($start<=0))
echo " <a href='search.php?search=$search&submit=Search+source+code&start=$prev'>Prev</a> ";
//pages
if ($max_pages < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
{
$i = 0;
for ($counter = 1; $counter <= $max_pages; $counter++)
{
if ($i == $start){
echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'><b>$counter</b></a> ";
}
else {
echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'>$counter</a> ";
}
$i = $i + $per_page;
}
}
elseif($max_pages > 5 + ($adjacents * 2)) //enough pages to hide some
{
//close to beginning; only hide later pages
if(($start/$per_page) < 1 + ($adjacents * 2))
{
$i = 0;
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($i == $start){
echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'><b>$counter</b></a> ";
}
else {
echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'>$counter</a> ";
}
$i = $i + $per_page;
}
}
//in middle; hide some front and some back
elseif($max_pages - ($adjacents * 2) > ($start / $per_page) && ($start / $per_page) > ($adjacents * 2))
{
echo " <a href='search.php?search=$search&submit=Search+source+code&start=0'>1</a> ";
echo " <a href='search.php?search=$search&submit=Search+source+code&start=$per_page'>2</a> .... ";
$i = $start;
for ($counter = ($start/$per_page)+1; $counter < ($start / $per_page) + $adjacents + 2; $counter++)
{
if ($i == $start){
echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'><b>$counter</b></a> ";
}
else {
echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'>$counter</a> ";
}
$i = $i + $per_page;
}
}
//close to end; only hide early pages
else
{
echo " <a href='search.php?search=$search&submit=Search+source+code&start=0'>1</a> ";
echo " <a href='search.php?search=$search&submit=Search+source+code&start=$per_page'>2</a> .... ";
$i = $start;
for ($counter = ($start / $per_page) + 1; $counter <= $max_pages; $counter++)
{
if ($i == $start){
echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'><b>$counter</b></a> ";
}
else {
echo " <a href='search.php?search=$search&submit=Search+source+code&start=$i'>$counter</a> ";
}
$i = $i + $per_page;
}
}
}
//next button
if (!($start >=$foundnum-$per_page))
echo " <a href='search.php?search=$search&submit=Search+source+code&start=$next'>Next</a> ";
}
}
}
?>
and now i want to Select the tables: Guests, News, Interviews. And also how do i do to if i search for a some guest or event it gives me the results of every news/interviews where the guest and/or event appears...
Thank you for your help
Hi, i have this bas_facebook.php to login with facebook on my website, but it gives me error with the exception:
if (!function_exists('curl_init')) {
throw new Exception('Facebook needs the CURL PHP extension.');
}
if (!function_exists('json_decode')) {
throw new Exception('Facebook needs the JSON PHP extension.');
}
/**
* Thrown when an API call returns an exception.
*
* @author Naitik Shah <naitik@facebook.com>
*/
class FacebookApiException extends Exception
{
/**
* The result from the API server that represents the exception information.
*/
protected $result;
(...)
This are the errors:
( ! ) Fatal error: Uncaught exception 'Exception' with message 'Facebook needs the CURL PHP extension.' in C:\wamp\www\facebook\lib\base_facebook.php on line 19
( ! ) Exception: Facebook needs the CURL PHP extension. in C:\wamp\www\facebook\lib\base_facebook.php on line 19
Thank you for replying, i will defenitly try that.
I was thinking of something more complex... What i'm trying to do is something like this http://tympanus.net/Tutorials/AnimatedFormSwitching/ but without closing the popup form...
Hi,
I have this popup with a Login Form (and a register form comment):
div id="login" style="float:right; width:15%; padding-top:3px;">
<a href="#" class="topopup">LOGIN | REGISTAR</a>
<div id="toPopup">
<div class="close"></div>
<div id="popup_content"> <!--your content start-->
<h2>Login</h2>
<form id="login">
<table cellpadding="3" cellspacing="2">
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="username" id="username" />
</td>
</tr>
<tr height="10px"></tr>
<tr>
<td>
Password:
</td>
<td>
<input type="password" name="password" id="password" />
<br/>
<span style="font-size:10px;"><a href="">Esqueceu-se da password?</a></span>
</td>
</tr>
<tr>
<td>
</td>
<td style="text-align:left;">
<input type="submit" name="login" id="login" />
<span style="font-size:12px;"><a href="">Ainda não está inscrito?</a></span>
</td>
</tr>
</table>
</form>
<!--
<form id="register">
<table cellpadding="3" cellspacing="2">
<tr>
<td>
Username:
</td>
<td>
<input type="text" name="username" id="username" />
</td>
</tr>
<tr height="10px"></tr>
<tr>
<td>
Password:
</td>
<td>
<input type="password" name="password" id="password" />
<br/>
<span style="font-size:10px;"><a href="#">Esqueceu-se da password?</a></span>
</td>
</tr>
<tr>
<td>
</td>
<td style="text-align:left;">
<input type="submit" name="login" id="login" />
<span style="font-size:12px;"><a href="#register">Ainda não está inscrito?</a></span>
</td>
</tr>
</table>
</form>
-->
</div> <!--your content end-->
</div> <!--toPopup end-->
<div class="loader"></div>
<div id="backgroundPopup"></div>
</div>
What i want is to change with a jquery effect the forms when i click in the anchor link
<span style="font-size:12px;"><a href="#register">Ainda não está inscrito?</a></span>
Can you help me, please?
Thank you
Hello, i have this table events:
id_evento, evento_texto, evento_banner, evento_image, evento_cartaz, evento_idioma
Now i can upload the image to evento_banner and evento_image, because they're the same only changes the size (the code is "inside" the <form>):
<?php
if(isset($_POST['Submit'])){
//Declara um Array para armazenar a mensagem de erro
$error = array();
//se o nome for entregue
if (empty($_POST['text'])){
$error[] = "text miss";
}else{
$text=$_POST['text'];
}
if (empty($_POST['cidade'])){
$error[] = "cidade";
}else{
$cidade=$_POST['cidade'];
}
if (empty($_FILES["file"]["name"])){
$error[] = "Choose an image for the band";
}else{
$image=$_FILES["file"]["name"];
}
//send to Database if there's no error '
if (empty($error)) // If everything's OK...
{
$idioma=$_POST['idioma'];
error_reporting(0);
$change="";
$abc="";
define ("MAX_SIZE","2048");
function getExtension($str){
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
$errors=0;
if($_SERVER["REQUEST_METHOD"] == "POST")
{
$uploadedfile = $_FILES['file']['tmp_name'];
if ($image)
{
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")){
$change='<div class="notification n-error">Unknown Image extension </div> ';
$errors=1;
}else{
$size=filesize($_FILES['file']['tmp_name']);
if ($size > MAX_SIZE*1024){
$change='<div class="notification n-error">You have exceeded the size limit!</div> ';
$errors=1;
}
if($extension=="jpg" || $extension=="jpeg" ){
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}else if($extension=="png"){
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}else{
$src = imagecreatefromgif($uploadedfile);
}
echo $scr;
list($width,$height)=getimagesize($uploadedfile);
$newwidth=900;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
$newwidth1=300;
$newheight1=($height/$width)*$newwidth1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);
$filename = "../../images/bands/". $_FILES['file']['name'];
$file=explode(".".$extension, $_FILES['file']['name']);
$filename1 = "../../images/bands/".$file[0]."_small".".".$extension;
imagejpeg($tmp,$filename,100);
imagejpeg($tmp1,$filename1,100);
imagedestroy($src);
imagedestroy($tmp);
imagedestroy($tmp1);
}
}
}
//If no errors registred, print the success message
if(!$errors)
{
$image=explode('../', $filename);
$image1=explode('../', $filename1);
$insert=("INSERT INTO eventos(evento_texto, evento_cidade, evento_banner, evento_image, evento_idioma)
VALUES ('".$text."', '".$cidade."', '", '".$image[2]."', '".$image1[2]."', '".$idioma."')");
if(mysql_query($insert)){
header('Location: eventos.php');
}
else{
echo '<div class="notification n-error">'.mysql_error().'.</div>';
}
}
else{
echo '<div class="notification n-error">The band already exists!</div>';
}
}else{
//If the "error" array contains error msg , display them
echo '<div class="notification n-error" <ul>';
foreach ($error as $key => $values)
{
echo '<li>'.$values.'</li>';
}
echo '</ul></div>';
}
}
?>
My goal is to add a different image to evento_cartaz.
Can someone help me?
Thank You
Do i have to configurate localhost (wamp) because it gives me 500 Internal Error
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Nothing happened. Do you have another example that can help me.
This one is really confused, i don't understand it very much, and i never worked with .htaccess
Thank you,
PF2G
Hi,
i'm trying to make a textarea (WYSIWYG Text Editor) where i write a text and i can mention people from the Database.
so i found this website and it is excellent for what i want to do but how do i add a link to the person i mention? By link i mean a anchor tag.
Here's the website: http://podio.github.io/jquery-mentions-input/
Thank you for your help,
PF2G
Hi, i'm trying to do clean url's using .htaccess but i'm having problems.
Here i have my .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([a-z]+)\/([0-9]+)\/?$ parameter_letter_and_number.php?param=$1¶m2=$2 [NC]
RewriteRule ^([a-z]+)\/?$ $1.php [NC]
RewriteRule ^([0-9]+)\/?$ parameter_number.php?param=$1 [NC]
RewriteRule ^([0-9_]+)\/?$ parameter_number_and_underscore.php?param=$1 [NC]
</IfModule>
Here is my parameters page so i can test:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Clean URL tutorial with .htaccess and PHP by http://codeofaninja.com/</title>
</style>
</head>
<body>
<h1>Parameter: Letter and Number ONLY. This is parameter_letter_and_number.php</h1>
<?php
echo "PARAMETER VALUE 1: " . $_REQUEST['param'];
echo "<br />";
echo "PARAMETER VALUE 2: " . $_REQUEST['param2'];
?>
</body>
</html>
it should appear somthing like this:
http://localhost/clean-urls/post/143
but in that way gives me 404 Error it works only if the url is http://localhost/clean-urls/parameter_letter_and_number.php?param=post¶m2=143
Can someone help me please?
Thank You,
PF2G
I'm a rookie and we don't understand very much. Can you explain a little better, please?
Thank you
Hi,
I'm developing an APP for android which requires a database, i'm using mySQL, but haven't had any luck with it's connection, this is my code:
connection class:
public class MySQLConnect extends Activity{
public void onCreate(Bundle savedInstanceState) {
}
public static void connection(String[] args ) throws Exception{
Class.forName("com.mysql.jdbc.Driver");
Connection con=(Connection) DriverManager.getConnection("jdbc:mysql://localhost/prom.pt_test", "root", "root");
PreparedStatement statement = con.prepareStatement("SELECT * FROM users");
ResultSet result=statement.executeQuery();
while(result.next()){
System.out.println(result.getString(1) + "" + result.getString(2));
}
}
}
Android manifest:
<activity
android:name=".MySQLConnect"
>
startActivity:
Button testButton = (Button) findViewById(R.id.button1);
testButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(LoginScreen.this, MySQLConnect.class));
}
});
Am i doing anything wrong???
Any help would be appreciated.
Hi,
I'm developing a mobile app for the first time, but i'm having trouble with the export of the app so i can test it in a iPhone.
I already have the certificate and the provision file, but my certificate has the extionsion .cer and i need to have it with P12 format.
I can't use the OpenSSL program and i would like to ask your help with the conversion and some tips about the export of the file, because it's a little confuse to me :S
Appreciate your help,
PF2G
Hi,
I have this code that selects the value of a combobox and it inserts into a input:
<?php
echo '<input id="matr_input" style="margin-left:15px;margin-top:10px;" name="id_cat"></input>';
$select_images="SELECT * FROM categories WHERE id_category='"./*combobox value*/."'";
$query_images=mysql_query($select_images) or die(mysql_error());
$image=mysql_fetch_assoc($query_images);
?>
<?php
$nome_arquivo = $image['img_category'];
$arquivo = explode('images/', $nome_arquivo);
if($image['img_category']!=''){
echo '<div style="margin-left:15px;">'.$arquivo[1].'<a href="delete_category.php?id='.$image['id_category'].'"><img width="10" style="margin-top: 1px; margin-left: 2px;" src="cross-on-white.gif"></a></div> <br />';
}
?>
<script>
function displayVals() {
var singleValues = $("#gallery_category_filter").val();
var multipleValues = $("#multiple").val() || [];
$("input#matr_input").val("" +
singleValues +
"" +
multipleValues.join(", "));
}
$("select").change(displayVals);
displayVals();
</script>
But instead of a input i want it to insert in this query:Select
$select_images="SELECT * FROM categories WHERE id_category='"./*combobox value*/."'";
$query_images=mysql_query($select_images) or die(mysql_error());
$image=mysql_fetch_assoc($query_images);
Can someone help me, please?
Thank you,
PF2G
Hi,
I'm trying to do a list of news, but i only want today's news and news from the past what i don't want is future news(tomorrow,...).
So i'm doing if the date <=$curdate, but future news appear anyway, can you help me, plz?
<?php
$curdate = date("d/m/Y");
$row_noticias = getRows("SELECT n.id, str_to_date(n.data, '%d/%m/%Y') AS date, nl.id_noticia, nl.titulo, nl.descricao, nl.resumo
FROM `noticias` as n, `noticias_lang` as nl
WHERE n.id = nl.id_noticia AND
nl.lang='$current_lang' AND n.visivel=1 AND nl.visivel=1
ORDER BY date DESC LIMIT 1");
foreach($row_noticias as $key => $noticia)
{
echo $noticia['date'] < $curdate;
die;
$query_data=mysql_query("SELECT * FROM noticias WHERE data='".$curdate."'") or die(mysql_error());
$data=mysql_fetch_assoc($query_data);
if ($data['data'] < $curdate )
{
echo "<label>".formatdate($data['data'])."</label>";
echo "<a href='".$current_lang."/noticia/".$noticia['id_noticia']."'>".get_substr($noticia['resumo'], 140)."</a>";
}
}
?>
That's it, thanks man...
That's what i did JorgeM, but it stay everything seperated then i used
boder-collapse:collapse
But nothing happened
Hi, i'm trying to do a table with
border:1px solid #000000
But i want border between rows and columns.
Can someone help me, please?
Here's my table if it helps or something:
<table>
<thead rowspan=1>
<tr>
<td>Nome da Banda</td>
<td>Estilo</td>
<td>Atividade</td>
<td>Line Up Atual</td>
<td>Line Up Tour</td>
<td>Ex-Membros</td>
<td>Linguagem</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
Hi,
i'm working on a website where i have to edit products. but first i have to select a Simulator and inside that simulator i have a several products.
What i want to do is, select a Simulator on a combobox and then in other combobox appears me all products that belong to that simulator.
Do you understand?
Here's my code:
Onchange Script:
<!--COMBO to COMBO-->
<script>
$("select #simul").change(function () {
var str = "";
$("select #simul option:selected").each(function () {
str += $(this).text() + " ";
});
$("select .simulador").text(str);
})
.change();
</script>
<!--COMBO to TEXTBOX-->
<script>
$("select.simulador").change(function () {
var str = "";
$("select.simulador option:selected").each(function () {
str += $(this).text() + " ";
});
$("div .change_name").text(str);
})
.change();
</script>
<!----------------------------------------------->
Form:
<?php
$query_simulador=mysql_query("SELECT * FROM simulador") or die(mysql_error());
$titulo_sim=mysql_num_rows($query_simulador);
$query_prod_sim=mysql_query("SELECT * FROM produtos WHERE id_simulador='".$titulo_sim['id_simulador']."'") or die(mysql_error());
$prod_sim=mysql_fetch_assoc($query_prod_sim);
?>
<label for="edit-name" id="simul" class="label-help">Simulador: </label>
<select class="inp-form big_inp" name="simulador" id="titulo">
<?php
while ($titulo_sim=mysql_fetch_assoc($query_simulador))
{
?>
<option <?php if($simulador['titulo_simulador']==$titulo_sim['titulo_simulador']){echo 'selected="selected"';} ?>> <?php echo $titulo_sim['titulo_simulador']; ?> </option>
<?php
;}
?>
</select>
<div class="description">O nome de leitura fácil, deste tipo de conteúdo. Este texto será mostrado como parte da lista na página criar conteúdo. É recomendado que este nome comece com uma letra maiúscula e contenha apenas letras, números e espaços. Este nome tem de ser único.</div>
<br />
<label for="edit-name" class="label-help">Produto: </label>
<table>
<tr>
<td>
<input type="text" name="prod_name">
<div class="change_name" style="margin-top:-17px; margin-left:5px;"> </div>
</input>
</td>
<td width="20px"></td>
<td>
<select onchange="function()" name="produtos" class="simulador">
<option>
</option>
</select>
</td>
</tr>
</table>
Thank you,
PF2G