Hi Forums
When i doing following code, it do the query & show the result contain pages. but when i move to the next page that displays the error message.
the error message is :
Notice: Undefined index: h1 in C:\AppServ\www\facebook\findpepoles.php on line 65 (marked as ------error #1)
Notice: Undefined index: txtser in C:\AppServ\www\facebook\findpepoles.php on line 66 (marked as ------error #2)
i couldn't understand that? can any one explain that?
thanks
chel-1
5 1521 Atli 5,058
Expert 4TB
Hi.
And undefined index warning means that you are trying to use an array element that doesn't exist.
You need to find where that is happening and make sure the element does exist before you try to use it.
The isset function can help with that.
Hi.
And undefined index warning means that you are trying to use an array element that doesn't exist.
You need to find where that is happening and make sure the element does exist before you try to use it.
The isset function can help with that.
thanks atli.
i try to find that.
chel-1
hi
now my question is.... -
<?php
-
$con=mysql_connect("localhost","root","iceberg");
-
-
if(!$con){
-
die('could not connect:'.mysql_error());
-
}
-
mysql_select_db("mydata",$con);
-
-
-
-
-
-
-
// how many rows to show per page
-
$rowsPerPage = 2;
-
-
// by default we show first page
-
$pageNum = 1;
-
-
// if $_GET['page'] defined, use it as page number
-
if(isset($_GET['page']))
-
{
-
$pageNum = $_GET['page'];
-
}
-
-
// counting the offset
-
$offset = ($pageNum - 1) * $rowsPerPage;
-
-
echo "<table align='center' border='0'>";
-
-
$sql_fr=mysql_query("SELECT*FROM myfriends WHERE refno='$refno'");
-
while($row=mysql_fetch_array($sql_fr)){
-
$fref[$my]= $row['myfriend'];
-
-
$query = " SELECT * FROM user WHERE refno='$fref[$my]'" .
-
" LIMIT $offset, $rowsPerPage";
-
$result = mysql_query($query) or die('Error, query failed');
-
-
// print
-
while($row = mysql_fetch_array($result)){
-
$fname[$my]=$row['fullname'];
-
$photo[$my]=$row['prophoto'];
-
$em[$my]=$row['email'];
-
$bd[$my]=$row['birthdate'];
-
-
$em[$my]=substr($em[$my],0,strpos($em[$my],"/"));
-
$pos[$my]=strpos($fname[$my],' ');
-
$fname[$my]=substr($fname[$my],0,$pos[$my]);
-
-
$my+=1;
-
}
-
}
-
-
-
echo "<table align='center' border='0'>";
-
while($fr_c<$my){
-
echo"<tr><td rowspan='5' aligh='middle'><img src='img/".$photo[$fr_c]."' width='115' height='120'></td></tr>";
-
echo "<tr><td>".$fname[$fr_c]."</td><td width='200'></td><td><a href='viewgrps.php?$fref[$fr_c]'>View Groups</a></td></tr>";
-
echo "<tr><td>".$em[$fr_c]."</td><td width='200'></td><td><a href='fralbpage.php?$fref[$fr_c]'>View Albums</a></td></tr>";
-
echo "<tr><td>".$bd[$fr_c]."</td><td width='200'></td><td><a href='events.php'>View Events</a></td></tr>";
-
echo "<tr><td>Send Message</td></tr>";
-
echo"<tr><td> </td></tr>";
-
$fr_c+=1;
-
}
-
echo "</table>";
-
-
// how many rows we have in database
-
$query = "SELECT COUNT(refno) AS numrows FROM myfriends WHERE refno='$refno'";
-
$result = mysql_query($query) or die('Error, query failed');
-
$row = mysql_fetch_array($result, MYSQL_ASSOC);
-
$numrows = $row['numrows'];
-
-
// how many pages we have when using paging?
-
$maxPage = ceil($numrows/$rowsPerPage);
-
-
// print the link to access each page
-
$self = $_SERVER['PHP_SELF'];
-
$nav = '';
-
-
for($page = 1; $page <= $maxPage; $page++)
-
{
-
if ($page == $pageNum)
-
{
-
$nav .= " $page "; // no need to create a link to current page
-
}
-
else
-
{
-
$nav .= " <a href=\"$self?page=$page\">$page</a> ";
-
}
-
}
-
-
-
-
-
-
-
-
-
// creating previous and next link
-
// plus the link to go straight to
-
// the first and last page
-
-
if ($pageNum > 1)
-
{
-
$page = $pageNum - 1;
-
$prev = " <a href=\"$self?page=$page\">[Prev]</a> ";
-
-
$first = " <a href=\"$self?page=1\">[First Page]</a> ";
-
}
-
else
-
{
-
$prev = ' '; // we're on page one, don't print previous link
-
$first = ' '; // nor the first page link
-
}
-
-
if ($pageNum < $maxPage)
-
{
-
$page = $pageNum + 1;
-
$next = " <a href=\"$self?page=$page\">[Next]</a> ";
-
-
$last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
-
}
-
else
-
{
-
$next = ' '; // we're on the last page, don't print next link
-
$last = ' '; // nor the last page link
-
}
-
-
// print the navigation link
-
echo "<br><br>";
-
echo $first . $prev . $nav . $next . $last;
-
-
// and close the database connection
-
-
-
-
-
mysql_close();
-
-
?>
-
-
the above paging code find the num of rows on database & it define the upcoming pages. but my problem is on the next page doesn't have any data.
why?
thanks
chel-1
what comes to my mind is that you're trying to do a query while looping in the results of another query in this part. I'm not really sure if you could do that. I would recommend to first finish working with all the results from one query, store the info you need in an array and then work on the second query with that array OR create two links to the DB and then one query use it with one link and the other with the second link.
Cheers,
Gabo -
while($row=mysql_fetch_array($sql_fr)){
-
$fref[$my]= $row['myfriend'];
-
-
$query = " SELECT * FROM user WHERE refno='$fref[$my]'" .
-
" LIMIT $offset, $rowsPerPage";
-
$result = mysql_query($query) or die('Error, query failed');
-
-
// print
-
while($row = mysql_fetch_array($result)){
-
$fname[$my]=$row['fullname'];
-
$photo[$my]=$row['prophoto'];
-
$em[$my]=$row['email'];
-
$bd[$my]=$row['birthdate'];
-
-
$em[$my]=substr($em[$my],0,strpos($em[$my],"/"));
-
$pos[$my]=strpos($fname[$my],' ');
-
$fname[$my]=substr($fname[$my],0,$pos[$my]);
-
-
$my+=1;
-
}
-
}
-
what comes to my mind is that you're trying to do a query while looping in the results of another query in this part. I'm not really sure if you could do that. I would recommend to first finish working with all the results from one query, store the info you need in an array and then work on the second query with that array OR create two links to the DB and then one query use it with one link and the other with the second link.
Cheers,
Gabo -
while($row=mysql_fetch_array($sql_fr)){
-
$fref[$my]= $row['myfriend'];
-
-
$query = " SELECT * FROM user WHERE refno='$fref[$my]'" .
-
" LIMIT $offset, $rowsPerPage";
-
$result = mysql_query($query) or die('Error, query failed');
-
-
// print
-
while($row = mysql_fetch_array($result)){
-
$fname[$my]=$row['fullname'];
-
$photo[$my]=$row['prophoto'];
-
$em[$my]=$row['email'];
-
$bd[$my]=$row['birthdate'];
-
-
$em[$my]=substr($em[$my],0,strpos($em[$my],"/"));
-
$pos[$my]=strpos($fname[$my],' ');
-
$fname[$my]=substr($fname[$my],0,$pos[$my]);
-
-
$my+=1;
-
}
-
}
-
thanks Gabo!
now its working.
chel-1
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Li |
last post by:
Hi, guys,
I got a problem when trying to paging the recordset. the problem is
even I set the pagesize but the first page will always show all the
records and the number of records that shown on...
|
by: Paul Perot |
last post by:
Hi All:
I am populating a Data Table with File/Folder information from my drive... I
am then binding this data table to a DataGrid. Due to the size of the
DataGrid data, I use the built in...
|
by: asad |
last post by:
Hello friends, i am designing a ASP.NET page where i want to use custom
paging bcoz data is too heavy so pls tell me how can i use custom paging in
ASP.NET
Thanks
|
by: hlubocky |
last post by:
I thought I had a good grasp of the problem related to dynamically
creating controls, but it appears that as my application grew in
complexity, the problem has resurfaced. As I understand it, in...
|
by: LRK |
last post by:
Earlier this week we set up a second application pool to be able to implement
trusted connections between ASP.NET apps and a SQL Server database on a
different server.
The trusted connection is...
|
by: anonieko |
last post by:
This approach I found very efficient and FAST when compared to the
rowcount, or Subquery Approaches.
This is before the advent of a ranking function from DB such as
ROW_NUMBER() in SQL Server...
|
by: Chuck |
last post by:
I'm setting the column with for a gridview (25+- columns) and have
paging turned on.
When the gridview is first displayed, the column widths are all set to
the default. But after paging to...
|
by: Donald Adams |
last post by:
Hi,
I will have both web and win clients and would like to page my data. I
could not find out how the datagrid control does it's paging though I did
find some sample code that says they do it...
|
by: m.gelosa |
last post by:
Dear all,
I got a problem on db2 for aix running a high workload messaging
system with more than 5,000,000 of deliveries per day. During high
peak hours it happens frequently that the...
|
by: webaccess |
last post by:
Hi Friends ..!!
I want to use datagrid/dataview control to data in tablular format,also I want to add paging and format the data of table column.
Problem is data is coming from API Dom in as...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
| |