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 1594 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: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |