Quantcast
Channel: PHP Freaks: PHP Help
Viewing all 13200 articles
Browse latest View live

if to case conversion

$
0
0

I'm stumped on how to convert the if statement to a case statement

if ($page>=3 && $page<4)

case (>='3' && <'4'):

It's doing the block inside when the case variable isn't set.


make a website summary

$
0
0

i need to make a php function which will summarize a website content.  the idea is to get all those content using Simple html dom parsar

, then match some lines with the keyword and return them. i know how to fetch content, but can't understand how to match the keywords      with lines, then pick the most matched lines! later, i found this great article http://stackoverflow.com/questions/1195947/best-practices-on-displaying-search-results-with-associated-text-snippets-from-a#1201464

 but cant configure!

 i wish something like this > http://smmry.com/ as a beginning prog. i can't understand how to do this ... pls pls help me :)

How not to display admin when fetching data from mysql user table

$
0
0

Dear users,

 

I am trying to disregard ADMIN when displaying registered users from USERS table.

 

The code I am using is

if($session->isAdmin()) {$query="SELECT username FROM users ";}

This gives me all the users from the database. What I want to do is not to display ADMIn and display the rest of the users.

 

is it possible? Could anyone help?

Value of Subdomain

$
0
0

Hi Everyone

 

This stuff is well beyond my understanding.

 

I have been using the code below written by JKG http://forums.phpfreaks.com/topic/234954-how-to-get-the-value-of-subdomain/?hl=%2Bfind+%2Bsubdomain#entry1208823  And it has been working flawlessly, until I ran into something unexpected. 

 

It doesn't work with usernames (subdomains) that contain a dot "." For instance john.doe http://www.john.doe.mysite.com

<?php
$url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . $_SERVER['QUERYSTRING'];
$urlParts = explode('.', $_SERVER['HTTP_HOST']);
if(strpos($url, 'www')){
$subdomain_value = $urlParts[1];
} else { 
$subdomain_value = $urlParts[0]; 
};
echo $subdomain_value;
?>

For my application, anything between the www. and .mysite.com is the subdomain ie username. So with http://www.this.is.the.username.mysite.com username =  this.is.the.username  Although I have not run across anyone with more then one dot in their username, the possibility exists. Doubtful if any username would have more than 2 dots.

 

Background info: I have wildcard subdomain redirected to root. Works without needing any htaccess. The subdomain is just a placeholder for username. Then I use php to pull out the username (subdomain) and retrieve their saved info from mysql.

 

As I said, I am way over my head. Anyone know of a solution? 

 

Thanks Tom

 

 

 

 

 

 

 

 

 

 

Please help with this Downline Builder.

$
0
0

Hello Everyone, I am happy to be here. I really need some help. This is the situation. I have a downline / Team Builder script. The admin get to place programs from the admin panel and it saves correctly. The purpose of the team build section is for when someone joins a program and puts their referral link in the back office, their downline gets to see their sponsors referral link for that particular program. 

 

The problem is the downline can not see their sponsor referral link. It takes them directly to the admin's referral link. It does save when the sponsor places their link and I also checked in myadminPHP. Everyone's referral links from the programs are in the database. If you can take a quick look, I would really appreciate it. I have been going nuts trying to figure out the issue. Here is the code for the entire page. 

<?php

session_start();

include "../config.php";
include "../header.php";
include "../style.php";

if( isset($_SESSION["ulogin"]) )
   	{  // members only stuff!
		include("navigation.php");
        include("../banners2.php");

        echo "<font size=2 face='$fonttype' color='$fontcolour'><p><center>";
		echo "<br><center><font size=6><img src=images/downlinebuilder.png></font></center><br><div align=\"left\">";

		$query1 = "SELECT * FROM pages WHERE name='Downline Builder'";
	    $result1 = mysql_query ($query1);

	    $line1 = mysql_fetch_array($result1);
	         $htmlcode = $line1["htmlcode"];

	    echo dbget($htmlcode);


if($_POST['update']) {

	$sid = intval($_POST['sid']);
	$info = htmlentities($_POST['info']);
	
	$sql = mysql_query("SELECT * FROM builder WHERE userid = '".$userid."'");
	if(!@mysql_num_rows($sql)) {
		mysql_query("INSERT INTO builder (userid, site".$sid.") VALUES ('".$userid."', '".dbput($info)."')");
	} else {
		mysql_query("UPDATE builder SET site".$sid." = '".dbput($info)."' WHERE userid = '".$userid."'");
	}
}


if($_POST['favorite']) {

	if(($fav1_url OR $fav1_title) AND ($fav1_url == "" OR $fav1_title == "")) {
		$fav1_url = "";
		$fav1_title = "";
		$fav1_desc = "";		
		$msg1 = "<font color=red>You need to fill all the fields.</font>";
	}
	

	if(($fav2_url OR $fav2_title) AND ($fav2_url == "" OR $fav2_title == "")) {
		$fav2_url = "";
		$fav2_title = "";
		$fav2_desc = "";		
		$msg2 = "<font color=red>You need to fill all the fields.</font>";
	}
	
	if(($fav3_url OR $fav3_title) AND ($fav3_url == "" OR $fav3_title == "")) {
		$fav3_url = "";
		$fav3_title = "";
		$fav3_desc = "";		
		$msg3 = "<font color=red>You need to fill all the fields.</font>";
	}




	$sql = mysql_query("SELECT * FROM builder WHERE userid = '".$userid."'");
	$fav1_title = dbput($fav1_title);
	$fav2_title = dbput($fav2_title);
	$fav3_title = dbput($fav3_title);
	$fav1_url = dbput($fav1_url);
	$fav2_url = dbput($fav2_url);
	$fav3_url = dbput($fav3_url);
	$fav1_bold= dbput($fav1_bold);
	$fav2_bold= dbput($fav2_bold);
	$fav3_bold= dbput($fav3_bold);
	$fav1_color= dbput($fav1_color);
	$fav2_color= dbput($fav2_color);
	$fav3_color= dbput($fav3_color);
	if(!@mysql_num_rows($sql)) {
		mysql_query("INSERT INTO builder (userid, fav1_title, fav2_title, fav3_title, fav1_url, fav2_url ,fav3_url,fav1_bold,fav1_color,fav2_bold,fav2_color,fav3_bold,fav3_color) VALUES ('".$userid."', '".$fav1_title."', '".$fav2_title."', '".$fav3_title."', '".$fav1_url."', '".$fav2_url."', '".$fav3_url."', '".$fav1_bold."', '".$fav1_color."', '".$fav2_bold."', '".$fav2_color."', '".$fav3_bold."', '".$fav3_color."')");
	} else {
		mysql_query("UPDATE builder SET fav1_title = '".$fav1_title."',fav2_title = '".$fav2_title."',fav3_title = '".$fav3_title."',fav1_url = '".$fav1_url."',fav2_url = '".$fav2_url."',fav3_url = '".$fav3_url."',fav1_bold = '".$fav1_bold."',fav1_color = '".$fav1_color."',fav2_bold = '".$fav2_bold."',fav2_color = '".$fav2_color."',fav3_bold = '".$fav3_bold."',fav3_color = '".$fav3_color."' WHERE userid = '".$userid."'");
	}
}


//Get the user links
$ub = array();
$sql = mysql_query("SELECT * FROM builder WHERE userid = '".$userid."'");
if(@mysql_num_rows($sql)) $ub = mysql_fetch_array($sql);



$sql = mysql_query("SELECT * FROM builder_fav");
while($each = mysql_fetch_array($sql)) {
	$fav[$each['id']] = array('title' => $each['title'],'desc' => $each['desc'],'url' => $each['url']);
}


echo "<center>";
// Builder

echo "</center>";


?>
	  
	  
	  <br><br>
	  <center>
	  <h3>Your favorite programs</h3>
	  <form action="builder.php" method="post">
	  <input type="hidden" name="favorite" value="1">
		  <p><b>Site 1</b></p>
		  <? if($msg1) echo $msg1; ?>
		  <table>
		   <tr><td>Text:</td><td><input maxlength="65" type="text" name="fav1_title" value="<? echo $ub['fav1_title']; ?>"></td></tr>
		   <tr><td>Url:</td><td><input type="text" name="fav1_url" value="<? echo $ub['fav1_url']; ?>"></td></tr>
		   <tr><td>Bold:</td><td><input type="radio" name="fav1_bold" value="1"<? if($ub['fav1_bold']==1) echo ' CHECKED'; ?>> Yes <input type="radio" name="fav1_bold" value="0"<? if($ub['fav1_bold']==0) echo ' CHECKED'; ?>> No</td></tr>
		   <tr><td>Color:</td><td><input type="radio" name="fav1_color" value="red"<? if($ub['fav1_color']=='red') echo ' CHECKED'; ?>> <font color=red>Red</font> <input type="radio" name="fav1_color" value="blue"<? if($ub['fav1_color']=='blue') echo ' CHECKED'; ?>> <font color=blue>Blue</font> <input type="radio" name="fav1_color" value="green"<? if($ub['fav1_color']=='green') echo ' CHECKED'; ?>> <font color=green>Green</font> <br><input type="radio" name="fav1_color" value="black"<? if($ub['fav1_color']=='black' OR !$ub['fav1_bold']) echo ' CHECKED'; ?>> <font color=black>Black</font> <input type="radio" name="fav1_color" value="purple"<? if($ub['fav1_color']=='purple') echo ' CHECKED'; ?>> <font color=purple>Purple</font> <input type="radio" name="fav1_color" value="pink"<? if($ub['fav1_color']=='pink') echo ' CHECKED'; ?>> <font color=pink>Pink</font></td></tr>
		  </table>
		  
		  <p><b>Site 2</b></p>
		  <? if($msg2) echo $msg2; ?>
		  <table>
		   <tr><td>Text:</td><td><input maxlength="65" type="text" name="fav2_title" value="<? echo $ub['fav2_title']; ?>"></td></tr>
		   <tr><td>Url:</td><td><input type="text" name="fav2_url" value="<? echo $ub['fav2_url']; ?>"></td></tr>
		   <tr><td>Bold:</td><td><input type="radio" name="fav2_bold" value="1"<? if($ub['fav2_bold']==1) echo ' CHECKED'; ?>> Yes <input type="radio" name="fav2_bold" value="0"<? if($ub['fav2_bold']==0) echo ' CHECKED'; ?>> No</td></tr>
		   <tr><td>Color:</td><td><input type="radio" name="fav2_color" value="red"<? if($ub['fav2_color']=='red') echo ' CHECKED'; ?>> <font color=red>Red</font> <input type="radio" name="fav2_color" value="blue"<? if($ub['fav2_color']=='blue') echo ' CHECKED'; ?>> <font color=blue>Blue</font> <input type="radio" name="fav2_color" value="green"<? if($ub['fav2_color']=='green') echo ' CHECKED'; ?>> <font color=green>Green</font> <br><input type="radio" name="fav2_color" value="black"<? if($ub['fav2_color']=='black' OR !$ub['fav2_bold']) echo ' CHECKED'; ?>> <font color=black>Black</font> <input type="radio" name="fav2_color" value="purple"<? if($ub['fav2_color']=='purple') echo ' CHECKED'; ?>> <font color=purple>Purple</font> <input type="radio" name="fav2_color" value="pink"<? if($ub['fav2_color']=='pink') echo ' CHECKED'; ?>> <font color=pink>Pink</font></td></tr>
		  </table>
		  
		  <p><b>Site 3</b></p>
		  <? if($msg3) echo $msg3; ?>
		  <table>
		   <tr><td>Text:</td><td><input maxlength="65" type="text" name="fav3_title" value="<? echo $ub['fav3_title']; ?>"></td></tr>
		   <tr><td>Url:</td><td><input type="text" name="fav3_url" value="<? echo $ub['fav3_url']; ?>"></td></tr>
		   <tr><td>Bold:</td><td><input type="radio" name="fav3_bold" value="1"<? if($ub['fav3_bold']==1) echo ' CHECKED'; ?>> Yes <input type="radio" name="fav3_bold" value="0"<? if($ub['fav3_bold']==0) echo ' CHECKED'; ?>> No</td></tr>
		   <tr><td>Color:</td><td><input type="radio" name="fav3_color" value="red"<? if($ub['fav3_color']=='red') echo ' CHECKED'; ?>> <font color=red>Red</font> <input type="radio" name="fav3_color" value="blue"<? if($ub['fav3_color']=='blue') echo ' CHECKED'; ?>> <font color=blue>Blue</font> <input type="radio" name="fav3_color" value="green"<? if($ub['fav3_color']=='green') echo ' CHECKED'; ?>> <font color=green>Green</font> <br><input type="radio" name="fav3_color" value="black"<? if($ub['fav3_color']=='black' OR !$ub['fav3_bold']) echo ' CHECKED'; ?>> <font color=black>Black</font> <input type="radio" name="fav3_color" value="purple"<? if($ub['fav3_color']=='purple') echo ' CHECKED'; ?>> <font color=purple>Purple</font> <input type="radio" name="fav3_color" value="pink"<? if($ub['fav3_color']=='pink') echo ' CHECKED'; ?>> <font color=pink>Pink</font></td></tr>
		  </table>
		  <br><input type="submit" value="Submit">
		  </form>
		  </center>
		  <br>


<?

$lastcat = "";
//Get the links for each site
$slist = mysql_query("SELECT s.*,c.name as catname FROM builder_sites s JOIN builder_cat c ON s.category=c.id ORDER BY c.order, s.category, s.order ASC");
while($each = mysql_fetch_array($slist)) {

	$user = $userid;
	$found = 0;

	while($found == 0) {

		//Referrer exists?
		       $sql = mysql_query("SELECT m.referid FROM members m JOIN members r ON m.referid = r.id WHERE m.userid = '".$user."'");

		if(@mysql_num_rows($sql)) {
		
			$referrer = mysql_result($sql, 0);
			
			$sql = mysql_query("SELECT site".$each['id']." FROM builder WHERE userid = '".$referrer."'");
			if(@mysql_num_rows($sql)) {
			
				// Found a row, check if it's empty
				$value = mysql_result($sql, 0);
				if($value) {
					//found a link, end the loop
					$links = $value;
					$found = 1;
				} else {
					//No link, next.
					$user = $referrer;
				}
				
			} else {
				//No row, next.
				$user = $referrer;
			}

		} else {
			//No more referrers, use default values
			$links = $each['url'];
			$found = 1;
		}

	}
	
	if($lastcat != $each['category']) echo "<br><center><h2>".$each['catname']."</h2></center><hr>";
	$lastcat = $each['category'];	
	
	?>
	
	
	  <h3><a href="<? echo $links; ?>" target=_new"><? echo $each['name']; ?></a></h3>
	  
	  <p><? echo $each['desc']; ?></p> 
	  <div style="text-align: right;">
	  <form method="post"><input type="hidden" name="sid" value="<? echo $each['id']; ?>">My referral link: <input type="text" name="info" value="<? echo $ub["site".$each['id']]; ?>"><input type="submit" name="update" value="Update"></form>
	  </div>
	  
	  <hr>
	
	
	
	<?
	
	
	

}
		echo "<br><br></div>";
        echo "</font></td></tr></table>";
	}

else
  { ?>

  <font size=2 face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>"><p><b><center>You must be logged in to access this site. Please <a href="<? echo $domain; ?>/memberlogin.php">click here</a> to login.</p></b></font><center>

  <? }

include "../footer.php";
mysql_close($dblink);
?>

Here is the section where the banners and sponsor links are displayed and also the section where the current user places their referral links to be saved for their downline. 

?>
	
	
	  <h3><a href="<? echo $links; ?>" target=_new"><? echo $each['name']; ?></a></h3>
	  
	  <p><? echo $each['desc']; ?></p> 
	  <div style="text-align: right;">
	  <form method="post"><input type="hidden" name="sid" value="<? echo $each['id']; ?>">My referral link: <input type="text" name="info" value="<? echo $ub["site".$each['id']]; ?>"><input type="submit" name="update" value="Update"></form>
	  </div>
	  
	  <hr>
	
	
	
	<?

Thank you so much everyone. ~Johnny

LOOK UP Primary keys in a table and get the keys in assoc array

$
0
0
I am trying to look up a table and get the primary keys of the table into an assoc array , the below code is working for 1 primary key but its not working for  more than 1 primary keys in a table.
 
Could any one please help  me in this. , I am a beginner in php.
 
 
 
$getPrimaryKeys="SELECT k.COLUMN_NAME FROM information_schema.table_constraints t LEFT JOIN information_schema.key_column_usage k
USING(constraint_name,table_schema,table_name) WHERE t.constraint_type='PRIMARY KEY'    AND t.table_schema='".$schemaname."' AND t.table_name='".$table."';";
$results=mysql_query($getPrimaryKeys);
$priKeys=mysql_fetch_assoc($results)
<pre>
print_r($priKeys);
</pre>

connection with mysql

$
0
0

hello, i have a table of 7 columns (ID, Date, Snack1, Snack2, Snack3, Snack4, Snack5)

what am trying to do is the user will input his snack (string) and by clicking submit, the code written must check for the empty snacks columns in the table and place the string there if the ID and Date are the same (same user at the same day)
unfortunately, the code is always overwriting on Snack1. 
this means Snack1 is always empty though its not in the db!!

any help??

 

$sQuery = "SELECT * FROM caloriescounter where ID=$clid AND Date = '$date'";
$sResult = mysqli_query($con,$sQuery);
$row = mysqli_fetch_array($sResult);
 
if($row['Snack1']=="")
{
$foodS = '';
foreach ($_SESSION['foodTypes'] as $food)
{
$foodS= $foodS . $food . ", ";
}
$sql="";
$sql = "INSERT INTO caloriescounter (ID, Date, Snack1, Calories)
VALUES ($clid, '$date','$foodS', $total)
ON DUPLICATE KEY UPDATE Snack1 = '$foodS', Calories=$total";
 
var_dump($sql);
 
echo 'The amount of Calories registered is: ' . $total;
$result = mysqli_query($con, $sql) or die(mysqli_error());
 
mysqli_close($con);
 
// session exists and has content
// process the array list here.
// after the processing, empty the session
$_SESSION['foodTypes'] = array();
//break;
}
 
else if($row['Snack2']=="")
{
$foodS = '';
foreach ($_SESSION['foodTypes'] as $food)
{
$foodS= $foodS . $food . ", ";
}
$sql="";
$sql = "INSERT INTO caloriescounter (ID, Date, Snack2, Calories)
VALUES ($clid, '$date','$foodS', $total)
ON DUPLICATE KEY UPDATE Snack2 = '$foodS', Calories=$total";
 
var_dump($sql);
 
echo 'The amount of Calories registered is: ' . $total;
$result = mysqli_query($con, $sql) or die(mysqli_error());
 
mysqli_close($con);
 
$_SESSION['foodTypes'] = array();
break;
 }
 
else if($row['Snack3']=="")
{
$foodS = '';
foreach ($_SESSION['foodTypes'] as $food)
{
$foodS= $foodS . $food . ", ";
}
$sql="";
$sql = "INSERT INTO caloriescounter (ID, Date, Snack3, Calories)
VALUES ($clid, '$date','$foodS', $total)
ON DUPLICATE KEY UPDATE Snack3 = '$foodS', Calories=$total";
 
var_dump($sql);
 
echo 'The amount of Calories registered is: ' . $total;
$result = mysqli_query($con, $sql) or die(mysqli_error());
 
mysqli_close($con);
 
$_SESSION['foodTypes'] = array();
break;
}
 
else if($row['Snack4']=="")
{
$foodS = '';
foreach ($_SESSION['foodTypes'] as $food)
{
$foodS= $foodS . $food . ", ";
}
$sql="";
$sql = "INSERT INTO caloriescounter (ID, Date, Snack4, Calories)
VALUES ($clid, '$date','$foodS', $total)
ON DUPLICATE KEY UPDATE Snack4 = '$foodS', Calories=$total";
 
var_dump($sql);
 
echo 'The amount of Calories registered is: ' . $total;
$result = mysqli_query($con, $sql) or die(mysqli_error());
 
 
mysqli_close($con);
 
$_SESSION['foodTypes'] = array();
break;
 }
 
else if($row['Snack5']=="")
{
$foodS = '';
foreach ($_SESSION['foodTypes'] as $food)
{
$foodS= $foodS . $food . ", ";
}
$sql="";
$sql = "INSERT INTO caloriescounter (ID, Date, Snack5, Calories)
VALUES ($clid, '$date','$foodS', $total)
ON DUPLICATE KEY UPDATE Snack5 = '$foodS', Calories=$total";
 
var_dump($sql);
 
echo 'The amount of Calories registered is: ' . $total;
$result = mysqli_query($con, $sql) or die(mysqli_error());
 
 
mysqli_close($con);
 
$_SESSION['foodTypes'] = array();
break;
}
 
else echo 'Cant add more snacks, limit is 5 snacks per day !! ';
 
}
 

Why is this data not being inserted into my database table?

$
0
0

I have the following code set up to insert data into my table. This is just a test to see if it will work before I go further into development.

 

I know I'm able to connect to my data as I have a message appear when that happens, but it won't insert data into the table for some reason.

$phoneNumber = "0786352373";
$firstName = "jennifer";
$lastName = "dunne";
$profilePicture = "";
$photo = "";
$video = "";
$text = "text is here yes yes eys";
$call = "call is here yes yes eys";
$activity = "this is jennifers activity";
$latitude = "-50.889473";
$longitude = "3.845738";
$date = "23/05/2012";
$time = "13:29";


$sql = "INSERT INTO member (phoneNumber, firstName, lastName, profilePicture, photo, video, text, call, activity, latitude, longitude, data, time) ";
$sql .= "VALUES ('$phoneNumber', '$firstName', '$lastName', '$profilePicture', '$photo', '$video', '$text', '$call', '$activity', '$latitude', '$longitude', '$data', '$time')";

if (!mysqli_query($sql, $con)) {
die('Error: ' . mysqli_error());
} else {
echo "Comment added";
}

mysqli_close($con);

I do get an error message come up, but all it says is the following and doesn't shine light on the situation at all.

Error:

I'm very new to mysql and always seem to struggle with it but want to get over my fear of it. :-)


Help needed with php/mysql script for pulling dates outof a table

$
0
0

Hello coder buddies,

I have made this table with all the dates of the years going upto 2063, to keep it simple, it contains 3 columns which have been pre-popluated, example as follows...


Actual table

 

AutoIncNo | BookingDate | Status

 

The calendar is in 2 parts.

1) Calendar to select a date

2) A list menu to select the amount of nights they wish to stay.

So I take the original date (the one they select) and rearrange the format to suit the table...

 

PHP Code:
$CalendarDate str_replace("/""-""$CalendarDate");

    
$QueryDate date("Y-m-d"strtotime($CalendarDate)); 

Connect to the database...
 

PHP Code:
include_once('../connect/connectdatabase.php'); 

Run the first query to check if the dates they require are available.

$QueryDate is the date they select

$NightsForQuery is the amount of nights they want to stay

 

PHP Code:
$CalendarQuery mysql_query("SELECT * FROM BookingsCalendar WHERE BookingDate='$QueryDate' LIMIT 1");

    while(
$row mysql_fetch_array($CalendarQuery)) {$AutoInc $row["AutoIncNo"];}


    
$AutoInc2 $AutoInc $NightsForQuery 2;


    
$SelectDates mysql_query("SELECT * FROM BookingsCalendar WHERE AutoIncNo BETWEEN $AutoInc AND $AutoInc2");

    while(
$row mysql_fetch_array($SelectDates)) {

        
$AutoIncNo $row["AutoIncNo"];
        
$BookingDate $row["BookingDate"];
        
$Status $row["Status"];

        if (
$Status == 'booked') {

            
$LastBookedDate $BookingDate
            
$LastAutoIncNo $AutoIncNo
            
$Handle 1;

        }

    } 
// End - while($row = mysql_fetch_array($SelectDates)) {



if ($Handle !== 1) {echo 'DATES AVAILABLE >> WRITE BOOKING CODE';} 

So if the handle is not equal to 1 its fine and they can book, but, if the dates arn't available (i.e, $Handle == 1) I need to check the closest available dates either side (before and after) the date they wanted where the Status is 'available' for the amount of nights they wish to stay...

So I set out to establish the first available date in either direction and thts where I got stuck. Looking at it I'm sure you could run a while loop to find the next available block inside the code above, but not sure how.
 

PHP Code:
$FirstDateQuery mysql_query("SELECT * FROM BookingsCalendar WHERE Status='available' AND AutoIncNo < $LastAutoIncNo ORDER BY AutoIncNo DESC LIMIT $NightsForQuery");
        
    while(
$row mysql_fetch_array($FirstDateQuery)) {
        
            
$AutoIncNo $row["AutoIncNo"];
            
$BookingDate $row["BookingDate"];
            
$Status $row["Status"];
            
            echo 
$BookingDate '   ';

           } 

Which works, but, it selects the previous 4 rows individually.

So for example, if someone tries to book from 2013.06.01 but cant because its 'booked' for the next 4 days, the above script runs and brings up 2013.05.31 - 2013.05.30 - 2013.05.29 - 2013.05.28 as a result.

But if one of those dates are booked it will skip it and give me the next one (selecting as it is the next 4 that meet the condition 'available')

So if say 2013.05.29 was booked it would show 2013.05.31 - 2013.05.30 - 2013.05.28 - 2013.05.27 missing out the day which is booked.

Now the thing is that we need the next 4 rows together (undivided/continuous/without breaks in the dates) which are 'available'.

If you have a better more efficient way or can adapt what is already here, that would be grand... My brain hurts lol.

Thank you, L-Plate

 

Need help placing a title bar along the top of our page

$
0
0

Hi Guys,

I have a website that has a homepage without a title bar but the rest of the pages in the site do have it. I want to apply this same bar to the homepage can anyone help. See below the 3 main pieces of code:

This is the code for the Header

<?php
?><!DOCTYPE html>
<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html <?php language_attributes(); ?>> <!--<![endif]-->

<!-- head -->
<head>

<!-- meta -->
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<?php if( mfn_opts_get('responsive') ) echo '<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">'; ?>

<title><?php
global $post;
if( mfn_opts_get('mfn-seo') && is_object($post) && get_post_meta( get_the_ID(), 'mfn-meta-seo-title', true ) ){
    echo stripslashes( get_post_meta( get_the_ID(), 'mfn-meta-seo-title', true ) );
} else {
    global $page, $paged;
    wp_title( '|', true, 'right' );
    bloginfo( 'name' );
    if ( $paged >= 2 || $page >= 2 ) echo ' | ' . sprintf( __( 'Page %s', 'bretheon' ), max( $paged, $page ) );
}
?></title>

<!-- stylesheet -->
<link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" media="all" />
<?php do_action('wp_styles'); ?>

<!-- wp_head() -->
<link rel="shortcut icon" href="<?php mfn_opts_show('favicon-img',THEME_URI .'/images/favicon.ico'); ?>" type="image/x-icon" />    

<?php if( is_single() ): ?>
<script>var switchTo5x=true;</script>
<script src="http://w.sharethis.com/button/buttons.js"></script>
<script>stLight.options({publisher: "ur-6568e777-919c-a5dd-ac31-98a6fa2e6b2d"}); </script>
<?php endif; ?>
<?php do_action('wp_seo'); ?>

<?php wp_head();?>
</head>

<!-- body -->
<body <?php body_class(); ?>>    
    <div id="Wrapper">
    
         <?php
            get_template_part( 'includes/header', 'top-area' );
    
             if( ! is_404() ){
                $slider = false;
                if( get_post_type()=='page' ) $slider = get_post_meta( get_the_ID(), 'mfn-post-slider', true );
                
                if( $slider ){
                    if( $slider == 'mfn-offer-slider' ){
                        // Mfn Offer Slider
                        get_template_part( 'includes/header', 'offer-slider' );
                    } else {
                        // Revolution Slider
                        echo '<div id="mfn-rev-slider">';
                            putRevSlider( $slider );
                        echo '</div>';
                    }
                } elseif( trim( wp_title( '', false ) ) ){
                    // Page title
                    echo '<div id="Subheader">';
                        echo '<div class="container">';
                            echo '<div class="sixteen columns">';
                                if( get_post_type()=='page' || is_single() ){
                                    echo '<h1>'. $post->post_title .'</h1>';
                                } else {
                                    echo '<h1>'. trim( wp_title( '', false ) ) .'</h1>';
                                }
                                mfn_breadcrumbs();
                            echo '</div>';
                        echo '</div>';
                    echo '</div>';
                }
            }
        ?>


This is the code for the Index page which is the homepage

<?php

get_header();
$sidebar = mfn_sidebar_classes();
?>

<!-- #Content -->
<div id="Content">
    <div class="container">

        <!-- .content -->
        <?php
            if( $sidebar ) echo '<div class="content">';
            echo '<div class="the_content the_content_wrapper">';
            
            while ( have_posts() )
            {
                the_post();
                get_template_part( 'includes/content', get_post_type() );
            }
            
            // pagination
            if(function_exists( 'mfn_pagination' )):
                mfn_pagination();
            else:
            ?>
                <div class="nav-next"><?php next_posts_link(__('← Older Entries', 'bretheon')) ?></div>
                <div class="nav-previous"><?php previous_posts_link(__('Newer Entries →', 'bretheon')) ?></div>
            <?php
            endif;
            
            echo '</div>';
            if( $sidebar ){
                echo '</div>';
            } else {
                echo '<div class="clearfix"></div>';
            }
        ?>    
        
        <!-- Sidebar -->
        <?php
            if( $sidebar ){
                get_sidebar( 'blog' );
            }
        ?>

    </div>
</div>


<?php get_footer(); ?>


This is the code for the inner pages which contain the title bar

<?php

get_header();
$sidebar = mfn_sidebar_classes();
?>
    
<!-- Content -->
<div id="Content">
    <div class="container">

        <!-- .content -->
        <?php
            if( $sidebar ) echo '<div class="content">';
            
            while ( have_posts() )
            {
                the_post();
                get_template_part( 'includes/content', 'page' );
            }

            if( $sidebar ){
                echo '</div>';
            } else {
                echo '<div class="clearfix"></div>';
            }
        ?>    
        
        <!-- Sidebar -->
        <?php
            if( $sidebar ){
                get_sidebar();
            }
        ?>

    </div>
</div>

<?php get_footer(); ?>

 

slide show in PHP

$
0
0

Hello,

 

Someone please help me how to do slide show of pictures in PHP.

 

Many thanks.

 

-P

validating user registration against value stored in database

$
0
0

Hi,

 

I am *slowly* developing a website for our gaming guild as a project to help me with my learning of php and MySQL. So far, any stumbling blocks i have encountered i have been able to overcome through using the mighty google and reinterpretation of code snippets posted to many various websites including stackoverflow and devshed. However, i can't seem to find any solutions that can help me with this problem i have encountered.

 

I want to be able to verify a new user account from an 'application form' they fill in. The theory is that a new prospect applies to join the guild by filling out a simple form. This form is then viewed by an admin and, if approved, that application is issued a unique application ID which the new member then uses as part of their main signup form for the guild site. This process uses two tables ('applications' and 'users'). All new applications are, naturally stored on the 'applications' table and registered users on the 'users' table.

 

In order to prevent fraudulent registrations or bot registrations, the ID issued to the new member is checked against the one stored on the 'applications' table and, if it passes, the new member is registered with the site on the 'users' table and their application is automatically erased from the 'applications' table as it's no longer needed.

 

The registration form uses $_POST methods to check that all data has been inputted and assigns them to variables for injection to the table. What i want to be able to do is check that the character string inputted in the 'application ID' text field fo the form matches the string stored in the 'applications' table. If it does, execute the injection to the 'users' tble and clean up the no longer needed data from the 'applications' table. If they don't match, throw an error and terminate the script. If you need to see what code I have then i'll happily post it, I haven't in this post as (a) it's already long enough and (b ) it's all fairly standard stuff, i'm just missing the bit that does the cross-checking....

 

Is there a simple solution to this? Or will it require a lot of coding? Any suggestions/examples would be most welcome :)

Link Generator

$
0
0

Hi My name is Mario
im not a really good php programmer but im trying to learn .

Anyway i would need some help with this 1

 

I wanna create a php script .

Lets say i have a site www.[site].com/user=11111&k2=xxxxx

 

I want the php script to try all the numbers of k2 till it gets the right page with no errors.

 

If someone help me i will give an appreciation gift to him.
TY
Need help fast

php ini not working (or doesn't seem to be)

$
0
0

As in the title - my PHP.ini doesn't seem to be working - I did move from a WAMP setup to an LAMP setup but i changed the files in my ini to reflect the different directories.

 

I have the following set in my php.ini:

include_path = ".:/var/sites/t/testing.indigoonline.co.uk/public_html/php"

However, when i try to require the file i get the following:

Warning: require_once(required.php) [function.require-once]: failed to open stream: No such file or directory in /var/sites/t/testing.indigoonline.co.uk/public_html/admin/index.html on line 4

Fatal error: require_once() [function.require]: Failed opening required 'required.php' (include_path='.:/usr/local/lib/php') in /var/sites/t/testing.indigoonline.co.uk/public_html/admin/index.html on line 4

It seems that the php.ini isn't having an effect - anyone have any ideas please? I know i'm probably just missing something really simple.

 

Thanks

 

 

Background image not showing

$
0
0

I am php newibe but not a CSS newbie.  Here is my css code:

wrap {
    background: url("images/backgrounds/bg-wrap.png") repeat-x scroll 0 295px transparent;
    margin: 0;
    padding: 0;
    width: 100%;
}

The image exists in this location and when I inspect it in firefox I can hover over the CSS and see it.

 

I cannot get it to display.

 

Here is my php code:

 <wrap>
                <div class="wrap">
                         <?php
                        $a = new Area('Wrap');
                        $a->display($c);
                        ?>

                </div>
        </wrap>

What am I doing wrong, I just want the image to display behind the body but above the footer.  Here is the website: http://carolinestreetptso.org/play/

 

Thanks in advance

Gary

Global Nerds

 


Anybody want to help a wannabe coder?

$
0
0
Hi there,
 
I'm trying to learn basic coding - starting with some work on my own website.  I'm trying to add a video frame in to a page on my website and have followed various advice online... but it's still not working.  Could somebody help me understand what I'm doing/not doing?
 
This is what I have so far.
 
Thanks in advance,
 
Lyndon
 
 
 
<?php
  $title = "THINK DIFFERENT[LY] – PR for startups.  From $175.";
  include('includes/header.php');
  
  $pgKeywords="PR, Public Relations, Toronto, StartUp, Entrepreneur, PR-on-demand, public relations and marketing, marketing plan plan"
  
  <section
  <?php
  include "https://www.youtube.com/watch?v=eY8owu-_n7Q"; 
  ?>
  </div>
  
  ?>
  <section class="row">
      <div class="span12">
        <div id="home">
<H1>Results. Not Retainers.</H2?>
</div>
      </div>
    </section>
    <meta name="keywords" CONTENT="Startup Public Relations, startup pr, pr for startups, startup pr firm, the public relations, public relations in, Toronto, StartUp PR, Entrepreneur, PR-on-demand, PAYG PR, Pay As You Go PR, Startup PR, THINK DIFFERENTLY, public relations for, startups, about public relations">
    
<?php
  include('includes/footer.php');
?>

Paypal register form.

$
0
0

Hey! 

I find some tutorials or scripts what register only if paypal pay is succeful.

Need help with inserting frames

$
0
0
Hi there,
 
I'm trying to add a frame to my site and learning as I go.  Can somebody help me understand what I'm doing wrong/not doing?

Thanks in advance,
 
Lyndon
 
 
<?php
  $title = "THINK DIFFERENT[LY] – PR for startups.  From $175.";
  include('includes/header.php');
  
  $pgKeywords="PR, Public Relations, Toronto, StartUp, Entrepreneur, PR-on-demand, public relations and marketing, marketing plan plan"
  
  <section
  <?php
  include "https://www.youtube.com/watch?v=eY8owu-_n7Q"; 
  ?>
  </div>
  
  ?>
  <section class="row">
      <div class="span12">
        <div id="home">
<H1>Results. Not Retainers.</H2?>
</div>
      </div>
    </section>
    <meta name="keywords" CONTENT="Startup Public Relations, startup pr, pr for startups, startup pr firm, the public relations, public relations in, Toronto, StartUp PR, Entrepreneur, PR-on-demand, PAYG PR, Pay As You Go PR, Startup PR, THINK DIFFERENTLY, public relations for, startups, about public relations">
    
<?php
  include('includes/footer.php');
?>

question regarding profile information

$
0
0

Good evening,

 

I am working on user profiles and wonder whether or not I should bother validating the facebook, twitter and skype fields? For example, checking the twitter name starts with the @ symbol etc.

 

I want to know what some of you would do, I don't really want to display an error for a bad social media name but I'm not sure if it standard practice to do so.

 

Simple question really but it will probably lead into more questions before the night is gone!

 

Thanks for your help and advice.

 

Kind regards,

 

L2c.

Need a little help from my friends

$
0
0

I'm having trouble getting a table to show up correctly (in a row and it's showing in just one column) 

 

After having me screw around with things trying to get it settled, I'm sure I've made it completely a mess. 

 

Anyone wanna help a girl out? 

Viewing all 13200 articles
Browse latest View live


Latest Images