Jump to content

no get parameters, is my syntax out somwhere?


wright67uk

Recommended Posts

For some reason i'm not passing any get parameters.  Is my syntax out? (line 33)

 

I'm using dreamweaver's syntax highlighter and it isn't showing any errors.

 

 

The form takes me to:  URL/update_win.php?     (note no   'id= ?  '

 

Any help would be great.

<?php

//connection
if ($mysqli->connect_error) {
    die('Connect Error: ' . $mysqli->connect_error);
}

$query = "SELECT id, date, horse, course, odds, time, tip, description FROM toptips order by date desc"; 
$result = $mysqli->query($query);

while($row = $result->fetch_array()) 
{ $rows[] = $row; }

foreach($rows as $row) 
{ 
$date = $row['date'];
$date = date("d/m/y", strtotime($date));
$id = $row['id'];

echo 
'<div style= "width:600px;">
	<div style="float:left; width:400px; margin-bottom:10px; margin-top10px;">
		('.$date.") " .
      	 $row['time'] . " " . 
      	 $row['course'] . " - " . 
       	 $row['horse'] . " " . 
      	 $row['odds'] . " " . 
      	 '<img src="' . $row['tip'] . '.png" alt=" '. $row['tip'] .' " height="42" width="42" style="float:right"><br>'. 
         $row['description'] . 
	'</div>
 	
       <div style= "float:right; width: 50px; margin-left:150px;"> 
       <form method="get" action="update_win.php?id='.$id.'">
       <input type="submit" value="add win"/>
       </form>
      
 	</div>

 </div>
 <div style="clear:both"/>
 <hr/>'
 
 ; }

$result->close();
$mysqli->close(); 

?>

When using the GET method the form creates the query string in the url through it's inputs. So the query string in your action gets erased. You can create a hidden input field and assign the id value to it. Sort of like

 

<form method="get" action="update_win.php">
<input type="hidden" value="'.$id.'" name="id">
<input type="submit" value="add win"/>

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.