Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6221167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:05:07+00:00 2026-05-24T08:05:07+00:00

I’m trying to use php with mysql. basically i’ve an index page where user

  • 0

I’m trying to use php with mysql. basically i’ve an index page where user fills a form and another page where all rows are displayed. i’ve checkboxes for each row for deleting the selected row/rows. i’m trying to create a new page (namely details) where it shows only the selected row.
I’m trying to use $_GET but i could not do it. maybe the syntax is wrong. any help is welcome.

here are the relative code parts:

display.php:

<?
require_once('auth.php');?>
<html>
<head>
<title>Goruntule</title>

<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="checkboxForm">
<?


require "config.php";           // All database details will be included here 

$page_name="display.php";

$start=$_GET['start'];        // To take care global variable if OFF
if(!($start > 0)) {                // This variable is set to zero for the first page
$start = 0;
}

$eu = ($start -0);                
$limit = 10;                                 // No of records to be shown per page.
$this1 = $eu + $limit; 
$back = $eu - $limit; 
$next = $eu + $limit; 


// WE have to find out the number of records in our table. We will use this to break the pages
$query2=" SELECT * FROM table1  ";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
/////// The variable nume above will store the total number of records in the table////

/////////// Now let us print the table headers ////////////////
$bgcolor="#f1f1f1";
echo "<TABLE width=80% align=center  cellpadding=5 cellspacing=0> <tr>";
echo "<td  bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='2'>#</font></td>";
echo "<td  bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='2'>ID</font></td>";
echo "<td  bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='2'>Time</font></td>";
echo "</tr>";

////////////// Now let us start executing the query with variables $eu and $limit  set at the top of the page///////////
$query=" SELECT * FROM table1  ORDER BY id DESC limit $eu, $limit ";
$result=mysql_query($query);
echo mysql_error();

//////////////// Now we will display the returned records in side the rows of the table/////////
while($rows = mysql_fetch_array($result))
{
if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
else{$bgcolor='#f1f1f1';}
echo "<tr>";
echo "<td><input name='checkbox[]' type='checkbox' value='" . $rows[id] . "'></td>";  
echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='1'>$rows[id]</font></td>"; 
echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='1'>$rows[DateTime]</font></td>"; 
echo "<td><a href=\"detail.php?var1=<?php echo $rows[id]; ?>\">Details</a></td>";
//here is the problematic line i guess
echo "</tr>";
}
echo "</table>";
////////////////////////////// End of displaying the table with records ////////////////////////

///// Variables set for advance paging///////////
$p_limit=100; // This should be more than $limit and set to a value for whick links to be breaked

$p_f=$_GET['p_f'];                // To take care global variable if OFF
if(!($p_f > 0)) {                         // This variable is set to zero for the first page
$p_f = 0;
}



$p_fwd=$p_f+$p_limit;
$p_back=$p_f-$p_limit;
//////////// End of variables for advance paging ///////////////
/////////////// Start the buttom links with Prev and next link with page numbers /////////////////
echo "<table align = 'center' width='50%'><tr><td  align='left' width='20%'>";
if($p_f<>0){print "<a href='$page_name?start=$p_back&p_f=$p_back'><font face='Verdana' size='2'>PREV $p_limit</font></a>"; }
echo "</td><td  align='left' width='10%'>";
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
if($back >=0 and ($back >=$p_f)) { 
print "<a href='$page_name?start=$back&p_f=$p_f'><font face='Verdana' size='2'>PREV</font></a>"; 
} 
//////////////// Let us display the page links at  center. We will not display the current page as a link ///////////
echo "</td><td align=center width='30%'>";
for($i=$p_f;$i < $nume and $i<($p_f+$p_limit);$i=$i+$limit){
if($i <> $eu){
$i2=$i+$p_f;
echo " <a href='$page_name?start=$i&p_f=$p_f'><font face='Verdana' size='2'>$i</font></a> ";
}
else { echo "<font face='Verdana' size='4' color=red>$i</font>";}        /// Current page is not displayed as link and given font color red

}


echo "</td><td  align='right' width='10%'>";
///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
if($this1 < $nume and $this1 <($p_f+$p_limit)) { 
print "<a href='$page_name?start=$next&p_f=$p_f'><font face='Verdana' size='2'>NEXT</font></a>";} 
echo "</td><td  align='right' width='20%'>";
if($p_fwd < $nume){
print "<a href='$page_name?start=$p_fwd&p_f=$p_fwd'><font face='Verdana' size='2'>NEXT $p_limit</font></a>"; 
}
echo "</td></tr></table>";


?>
<tr>
<td colspan="14" align="center" bgcolor="#FFFFFF">
<input name="delete" type="submit" id="delete" value="Delete">
<form>
<INPUT TYPE="BUTTON" VALUE="Previous" ONCLICK="window.location.href='http://......../util'"> 
</FORM></td>
</tr>
<?php

$checkbox=$_POST['checkbox'];
if($_REQUEST['delete']=='Delete'){
foreach($checkbox as $id => $value)
{$sql="DELETE FROM table1 WHERE id='$value'";
$result = mysql_query($sql);
}

if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=display.php\">";
}
}
?>
<a href="detail.php?var1=<?php echo $rows[id]; ?>">details</a>
<?
mysql_close();
?>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>

detail.php

<?php
require_once('auth.php');
$host="localhost";  
$username=""; 
$password=""; 
$db_name=""; 
$tbl_name="table1"; 

mysql_connect("$host", "$username", "$password")or die("Cannot connect ". mysql_error()); 
mysql_select_db("$db_name")or die("Cannot select DB ". mysql_error());

$num=$_GET['var1'];
$query = "SELECT * FROM table1 where id='$num'"; 

$result = mysql_query($query) or die(mysql_error());

$row = mysql_fetch_row($result) or die(mysql_error());
?>
<table border="0" align="center" cellspacing="1" cellpadding="0">
<tr>
<td><form name="form1" method="post" action="">
<table border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF">&nbsp;</td>
<td colspan="13" align="center" bgcolor="#FFFFFF"><strong>Bölge</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">#</td>
<td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td>
<td align="center" bgcolor="#FFFFFF"><strong>Time</strong></td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFFF">
<input name="checkbox[]" type="checkbox" value="<? echo $rows['id']; ?>"></td>
<td bgcolor="#FFFFFF" align="center"><? echo $row['13']; ?></td>
<td bgcolor="#FFFFFF" align="center"><? echo $row['0']; ?></td>
</tr>
<tr>
<td colspan="14" align="center" bgcolor="#FFFFFF">
<input name="delete" type="submit" id="delete" value="Delete">
<form>
<input type=button value="Close" onClick="javascript:window.close();">
</form> 
</tr>
<?php

$checkbox=$_POST['checkbox'];
if($_REQUEST['delete']=='Delete'){
foreach($checkbox as $key=>$value)
{$sql="DELETE FROM $tbl_name WHERE id='$value'";
$result = mysql_query($sql);
}

if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=display.php\">";
}
}
mysql_close();
?>
</table>
</form>
</td>
</tr>
</table>
<html><head><link href="loginmodule.css" rel="stylesheet" type="text/css" /></head></html>

As I’ve said, the only problem i’m guessing is with the syntax, or something small as i can echo the row when i gave the var1 a specific id.
I’m sorry if i’m reposting but i couldn’t find an answer. Thanks!

Edit: I’m thinking of deleting checkbox parts and adding gif links in the while loop where users can delete, edit or detailed view of the corresponding row. seems easier i guess.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:05:08+00:00Added an answer on May 24, 2026 at 8:05 am

    Make sure that the details link is within the while block.

    <?php
    while($rows = mysql_fetch_array($result)) {
        echo '<a href="detail.php?var1='.$rows[id].'">Details</a>';
    }
    ?>
    

    Looks like you should not be using double quotes.

    <? echo "$rows[id]" ?>
    

    Should be

    <?php echo $rows[id]; ?>
    

    I also suggest you use ‘id’ as the name of the get rather than ‘var1’. ‘var1’ does not mean anything whereas ‘id’ makes more sense.

    <a href="detail.php?id=<?php echo $rows[id]; ?>">Details</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I need to clean up various Word 'smart' characters in user input, including but
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
i want to parse a xhtml file and display in UITableView. what is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.