Jump to content

I need you PHPSENSEI, help solve my issues with php


$php_mysql$

Recommended Posts

need ta get pagination done

 

my code where i was the pagination

 

echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"2\" width=\"100%\">";

if(!count($Post))
{
    print 'no records';
}
else
{
    echo "<tr class=\"rowhead\">\n";
    echo "  <th>Image</th>\n";
    echo "  <th>Ad Title</th>\n";
    echo "  <th>Type</th>\n";
    echo "  <th>State </th>\n";
    echo "  <th>City/Town</th>\n";
    echo "  <th>Posted</th>\n";
    echo "</tr>\n";
    $rowClass = '';

    foreach($Post as $p)
    {
        $rowClass = ($rowClass!='row1') ? 'row1' : 'row2';

        $link = "<a href=\"details.php?name=$Name&ID=".$p['id']."\">{$p['title']}</a>";
        $state = str_replace('_', '  ', $p['state']);
        if(empty($p['image']))
        {
            $image = 'no image';
       } else
        {
            $image = "<img src=\"{$p['image']}\" width=\"50px\" height=\"50\" alt=\"{$p['image']}\"/>";
        }

        echo "<tr class=\"{$rowClass}\">\n";
        echo "  <td>{$image}</td>";
        echo "  <td>{$link}</td>";
        echo "  <td>{$p['type']}</td>\n";
        echo "  <td>{$state}</td>\n";
        echo "  <td>{$p['location']}</td>\n";
        echo "  <td>{$p['adtime']}</td>\n";
        echo "</tr>\n";
    }
    echo "</table>";
}

 

and my sql query

 

function getPosts($Name) {
		$posts = array();
		$sql    = "SELECT * FROM `tbl` AS p
            WHERE p.category = '".$Name."' ORDER BY p.time DESC";
		$rs = executeSql($sql);
		while($row = mysql_fetch_array($rs)) {
		$posts[] = $row;
		}
		return $posts;	
    }

Let me know

<?
// GET - page : Check if page veriables exist, ensure it is valid and numeric.	
if(!$_GET['page'] )
{	$validpage = 1;	}
else
{
	if(is_numeric($_GET['page'])== TRUE )
	{	$validpage = $_GET['page'];	}
	else
	{	$validpage = 1;	}
}
?>	
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td  bgcolor='#F8F8F8' width="2%"></td>
    <td  bgcolor='#F8F8F8'>
<table width="100%" border="0" cellspacing="0" cellpadding="1" >
<tr>
    	<td   bgcolor='#F8F8F8' colspan="1 >
	<div align="left"><strong>
<?
		$search_sql = "SELECT * FROM tablename WHERE fieldname LIKE '%".$search_value."%' OR fieldName  LIKE '%".$search_value."%' ORDER BY fieldname ASC;" ; 
		$search_res = mysql_query($search_sql);
		if(!$search_res)
		{  	die(" Could not query the database categories  : <br/>". mysql_error() ); }
		$search_num = mysql_num_rows($search_res);

		//To implement paging, determine the number of pages and the number of the result ( 5 )
		$pagesize = 5;// Page size
		$numpages = ceil($search_num/$pagesize);
		$limit = ($validpage - 1)*5;
?>
	</strong></div></td>
	<td  bgcolor='#F8F8F8' ><div align="right"><strong> Go to page
<?	
	for($i = 1; $i<= $numpages; $i++)
	{	echo "<a href='search.php?s=".$search_value."&page=".$i."'>".$i."</a>";	}
?>
	</strong></div>
	</div></td> 
    	</tr>
<?	
	// No record found display the table only one heading INFORMATION
	if( $search_num == 0 )
	{	
		echo "<tr><td colspan='6' bgcolor='#D6D6D6' height='30'align='center'><strong>Information </strong></td></tr>";
		echo "<tr><td colspan='6' bgcolor='#F8F8F8' height='70' align='center'><font size='2'><strong>No suitable matches were found.</strong></font></ul></td>";}
	else
	{
?>
	<tr>
	<td></td>
  	</tr>
	<tr>
    	<td colspan="6" bgcolor="#EFEFEF" >
	</td> 
    </tr>
</table>

mark topic as solved....oops I pulled a Sensei.. :o

 

People private message me constantly for help, so what you see as solved is not the same for me. I know your referring to this...

 

http://www.phpfreaks.com/forums/index.php?topic=340743.0

 

Ask the member himself.

 

v7776c.jpg

 

I love you AyKay7 <3

dude chill i'm just messing with you... :P

no homo....

 

p.s you are kinder than I am, I pointed php_mysql to a plethora of pagination tuts once..wants people to do the work for him/her...no thanks

 

and its AyKay47 not AyKay7...;)

 

I get PM's all the time...I ignore them...

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.