Jump to content

Recommended Posts

Yes it is. We could supply you all the code, but then you wouldn't learn anything and you would just have even more questions. So I suggest you go to one of the following websites and start reading the tutorials:

 

www.tizag.com

www.w3schools.com

Link to comment
https://forums.phpfreaks.com/topic/90528-some-help-if-possible/#findComment-464373
Share on other sites

this is my code if anyone can help

<html>
<head><title>Test</title></head>
<body>
<?php
$link = mysql_pconnect("localhost","silersi_admin","");
$db = mysql_select_db("ebay");

//determine what to do depending on the ?action= string in the url caused by the post in the form
switch($_GET['action'])
{
case "save":
Save();
break; //removing the break would allow the form to reload the modified data for further edit if necessary

default:
loadForm($_POST['id']);
break;
}

function loadForm($record_id)
{
//might need adjustment 
$sql = "SELECT `transID`, `ebayID`, `itemID`, `itemDes`, `email`, `Telephone`, `Status` FROM `ebay` WHERE `transID` = '"$record_id."'";
$result = mysql_query($sql) or die("sql error");
$row = mysql_fetch_array($result);

$strHTML = "<form method="post" action="".$PHP_SELF."?action=save">n"
."Item Description: <input type="text" name="desc" id="desc" value="".$row['itemDes']."" /><br />n"
."Status: <input type="text" name="status" id="status" value="".$row['Status']."" /><br />n"
."<input type="hidden" name="record_id" id="record_id" value="".$record_id."" />n"
."<input type="submit" value="Save" />n"
."</form>n";

/*this is just somethign i do out of habit, since sometimes you end up with many echo,
instead I build a string and echo it all at once*/
echo $strHTML;
}

function Save()
{
$sql = "UPDATE `silversi_orders` SET `itemDes`='".$_POST['desc']."', `Status`='".$_POST['status']."' "
"WHERE `transID`='".$_POST['record_id']."'";
mysql_query($sql) or die("Couldn't save data");
}
?>

</body></html>

Link to comment
https://forums.phpfreaks.com/topic/90528-some-help-if-possible/#findComment-465789
Share on other sites

Post the error message too please.

Taking a quick glance this line looks wrong:

 

$strHTML = "<form method="post" action="".$PHP_SELF."?action=save">n"

 

It should be

 

 

$strHTML = "<form method="post" action=\"".$PHP_SELF."?action=save\">n"

 

Thats still going to return an error, it should be this:

 

<?php

$strHTML = "<form method='post' action='".$PHP_SELF."?action=save'>n"
."Item Description: <input type='text' name='desc' id='desc' value='".$row['itemDes']."' /><br />n"
."Status: <input type='text' name='status' id='status' value='".$row['Status']."' /><br />n"
."<input type='hidden' name='record_id' id='record_id' value='".$record_id."' />n"
."<input type='submit' value='Save' />n"
."</form>n";

?>

Link to comment
https://forums.phpfreaks.com/topic/90528-some-help-if-possible/#findComment-465908
Share on other sites

Thats still going to return an error, it should be this:

 

<?php

$strHTML = "<form method='post' action='".$PHP_SELF."?action=save'>n"
."Item Description: <input type='text' name='desc' id='desc' value='".$row['itemDes']."' /><br />n"
."Status: <input type='text' name='status' id='status' value='".$row['Status']."' /><br />n"
."<input type='hidden' name='record_id' id='record_id' value='".$record_id."' />n"
."<input type='submit' value='Save' />n"
."</form>n";

?>

 

That is wrong too  ;D

 

NEVER, EVER, EVER, use double quotes when working with values that DON'T have to be evaluated - It wastes way too much CPU time.

 

<?php
$strHTML = '<form method="post" action="'. $PHP_SELF .'?action=save">'. "\n".
.'Item Description: <input type="text" name="desc" id="desc" value="'. $row["itemDes"]. '" /><br />'. "\n".
.'Status: <input type="text" name="status" id="status" value="'. $row["Status"]. '" /><br />'. "\n".
.'<input type="hidden" name="record_id" id="record_id" value="'. $record_id. '" />'. "\n".
.'<input type="submit" value="Save" />'. "\n".
.'</form>'. "\n";
?>

 

Link to comment
https://forums.phpfreaks.com/topic/90528-some-help-if-possible/#findComment-465933
Share on other sites

You should really do some research before you speak. You didn't specify "concatenation" or "putting variables within double quotes" so just saying what you said will confuse newbies into thinking there is no difference.  ;D

 

 

100,000 literation's of a string:

(variables in quotes)
Double:
0.234696 Time

Single:
0.035352 Time

(concatenation)
Double:
0.238109 Time

Single:
0.227169 Time

Link to comment
https://forums.phpfreaks.com/topic/90528-some-help-if-possible/#findComment-467166
Share on other sites

100,000 literation's of a string

 

Exactly, it takes 100,000 iterations for that small change in time. That would be one large program, but yes, if you are making a program that big then using single quotes wouldn't be a bad idea. Otherwise if you have a relatively small script it really isn't a big deal.

Link to comment
https://forums.phpfreaks.com/topic/90528-some-help-if-possible/#findComment-467196
Share on other sites

right this is what i have now got

 

id.php5

<?
// Connect database. 
$host="localhost"; // Host name.
$db_user="silversi_admin"; // MySQL username.
$db_password=""; // MySQL password.
$database="silversi_orders"; // Database name.
mysql_connect($host,$db_user,$db_password);
mysql_select_db($database);

// Select all data records in table "name_list" and put them into $result.
$result=mysql_query("select * from ebay order by transID asc");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post" action="update.php5">
<table border="1" cellpadding="3" cellspacing="0">
<tr>
<td align="center" bgcolor="#FFCC00"><strong>TransID</strong></td>
<td align="center" bgcolor="#FFCC00"><strong>EbayID</strong></td>
<td align="center" bgcolor="#FFCC00"><strong>ItemID</strong></td>
<td align="center" bgcolor="#FFCC00"><strong>ItemDes</strong></td>
<td align="center" bgcolor="#FFCC00"><strong>Email</strong></td>
<td align="center" bgcolor="#FFCC00"><strong>Telephone</strong></td>
<td align="center" bgcolor="#FFCC00"><strong>Status</strong></td>
</tr>
<?
// Fetch record rows in $result by while loop and put them into $row.
while($row=mysql_fetch_assoc($result)){
?>
<tr>
<td bgcolor="#FFFFCC"><? echo $row['transID']; // Show record's ID ?></td>

<td bgcolor="#FFFFCC"><input name="name_<? echo $row['transID']; ?>" type="text" id="name_<? echo $row['transID']; ?>" value="<? echo $row['ebayID']; ?>" /></td>

<td bgcolor="#FFFFCC"><input name="name_<? echo $row['transID']; ?>" type="text" id="name_<? echo $row['transID']; ?>" value="<? echo $row['itemID']; ?>" /></td>

<td bgcolor="#FFFFCC"><input name="name_<? echo $row['transID']; ?>" type="text" id="name_<? echo $row['transID']; ?>" value="<? echo $row['itemDes']; ?>" /></td>

<td bgcolor="#FFFFCC"><input name="name_<? echo $row['transID']; ?>" type="text" id="name_<? echo $row['transID']; ?>" value="<? echo $row['email']; ?>" /></td>

<td bgcolor="#FFFFCC"><input name="name_<? echo $row['transID']; ?>" type="text" id="name_<? echo $row['transID']; ?>" value="<? echo $row['Telephone']; ?>" /></td>

<td bgcolor="#FFFFCC"><input name="name_<? echo $row['transID']; ?>" type="text" id="name_<? echo $row['transID']; ?>" value="<? echo $row['Status']; ?>" /></td>

</tr>
<? } // End while loop. ?>
</table>
<input type="submit" name="Submit" value="Update" />
</form>
</body>
</html>

 

update.php5

 

<?
if($_POST['Submit']){ // If receive Submit button variable.

// Connect database. 
$host="localhost"; // Host name.
$db_user="silversi_admin"; // MySQL username.
$db_password=""; // MySQL password.
$database="silversi_orders"; // Database name.
mysql_connect($host,$db_user,$db_password);
mysql_select_db($database);

// Select all data records in table "name_list" and put them into $result.
$result=mysql_query("select transid from ebay order by transID asc");

// Fetch record rows in $result by while loop and put them into $row.
while($row=mysql_fetch_assoc($result)){
// Get the posted value "name_ID value" from form.php5. This variable change it's value by while loop.
$name=$_POST["name_".$row[transID]];

// Update field "name", matching with "id" value by while loop.
mysql_query("update name_list set name='$name' where id='$row[transID]'");
}
echo "--- Update Complete ---";
}
?>

 

yet it does not update the data, if anyone can help please e-mail me at jack_wetson@hotmail.co.uk, as this site is banned at work, (filters)

Link to comment
https://forums.phpfreaks.com/topic/90528-some-help-if-possible/#findComment-467578
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.