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 7888337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:48:24+00:00 2026-06-03T05:48:24+00:00

I’m going to make edit menu in my web. so I direct the page

  • 0

I’m going to make edit menu in my web. so I direct the page from product into edit page. What I’m confused is how to get the productID from product’s page to use in edit page?
Here is my code in product

<?php $query= "SELECT * FROM game";
$rs = mysql_query($query);
while($data = mysql_fetch_array($rs)) { ?>
<div class="gameBox">
    <div style="margin:5px;">
        <?php echo "<image src=\"images/".$data['gameId'].".png\" alt=\"gameImage\" </image>"?>
        <div class="cleaner"></div>
        <div class="myLabel">Name</div><div>: <?php echo $data['gameName'];?></div>
        <div class="myLabel">Developer</div><div>: <?php echo $data['gameDeveloper']; ?></div>
        <div class="myLabel">Price</div><div>: $ <?php echo $data['gamePrice']; ?></div>
        <br />
        <a href="edit.php" <?php $id=$data['gameId'];?>><input type="button" value="Edit"/></a>
        <a href="<!-- Delete -->"><input type="button" value="Delete"/></a>
    </div>
</div>
<?php } ?>

and it’s my code in edit page

<?php include("connect.php");
$id[0] = $_REQUEST['id'];
$query = "SELECT * FROM game WHERE gameId=".$id."";
$rs = mysql_query($query);
while($data = mysql_fetch_array($rs)) { ?>
    <form action="doUpdate.php" method="post">
        <?php echo "<image src=\"images/".$id.".png\" alt=\"gameImage\" </image>"?>
        <div class="cleaner"></div>
        <div class="myLabel">Name</div><div>: <input type="text" value="<?php echo $data['gameName'];?>" id="gameName" name="gameName"/></div>
        <div class="myLabel">Developer</div><div>: <input type="text" value="<?php echo $data['gameDeveloper'];?>" id="gameDeveloper" name="gameDeveloper"/></div>
        <div class="myLabel">Price</div><div>: <input type="text" value="<?php echo $data['gamePrice'];?>" id="gamePrice" name="gamePrice"/></div>
        <br/>
        <div id="txtError">
        <!--error message here-->
        </div>
        <input type="submit" value="Submit"/>
        <a href="product.php"><input type="button" value="Cancel"/></span></a>
<?php } ?>

When I try to access edit page, there’s an error it said

"Undefined index:$id[0] = $_REQUEST['id'];" 

in edit page.
Could anyone help me?

  • 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-06-03T05:48:25+00:00Added an answer on June 3, 2026 at 5:48 am

    It looks like you’re confusing two methods of passing data between pages, forms and query strings in <a href...>s.

    Forms:

    Data is in <input>-type elements (or friends) and inside a <form...> tag.

    For example

    <form action="handler.php">
        <input type="text" name="var1" />
        <input type="text" name="var2" />
        <input type="submit">
    </form>
    

    Usually passed via POST and accessed in PHP via $_POST.

    For example, the values in the text boxes referenced above would be accessed with something like:

    <?php
    echo $_POST['var1'];  // First text box
    echo $_POST['var2'];  // Second text box
    

    Links:

    Passed as query strings in <a href...>, for example:

    <a href="http://www.yoursite.com/index.php?var1=foo&var2=bar">Click Me</a>
    

    Usually passed via GET and accessed in PHP via $_GET.

    For example, the values in the query string provided above would be accessed with something like

    <?php
    echo $_GET['var1'];  // "foo"
    echo $_GET['var2'];  // "bar"
    

    So in this case it looks like you’re hyperlinking an input button — which is not the usual way to do things, but you would fix it by changing this:

    <a href="edit.php" <?php $id=$data['gameId'];?>><input type="button" value="Edit"/></a>
    

    To, this

    <a href="edit.php?id=<?php echo $data['gameId'];?>"><input type="button" value="Edit"/></a>
    

    And then reference the variable in edit.php as $_GET['id'].

    But since you know it’s going to be an integer and nothing else, something like:

    $id = (int)$_GET['id'];
    

    Is good enough sanitation (at least for that variable).

    Lastly, I notice you assign a variable to $id[0] but then reference $id. Assigning a variable to $id[0] is not the same as assigning it to $id, as $id is an array in the former and an integer in the latter. It seems to me that you can just drop the [0] w.r.t. $id in your edit.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am currently running into a problem where an element is coming back from
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.