mysql related

Please observe the following code

[code]<?php
$host = “localhost”;
$login = “”;
$pswd = “”;
$db = “price”;
$tbl = array(
“cpu”=>“Processor”,
“mb”=>“Mainboard”,
“pc_case”=>“PC Case”,
“memory”=>“Memory”,
“storage”=>“Storage”,
“video”=>“Video Card”,
“pc_card”=>“PC Card”,
“tv_recv”=>“TV Receiver”,
“sat_dish_acc”=>“Satellite Dish & Accessories”,
“cooler”=>“Cooler”,
“monitor”=>“Monitor”,
“printer”=>“Printer”,
“scanner”=>“Scanner”,
“modem”=>“Modem”,
“lan”=>“LAN”,
“hub”=>“HUB”,
“speaker”=>“Speaker”,
“mouse_keyb”=>“Mouse & Keyboard”,
“surge_arrest”=>“Surge Arrest”);
//$num = count($tbl);
$con = mysql_connect($host, $login, $pswd) or die ("Error Message: ".mysql_error());
?>
mysql_select_db($db) or die ("Error Message: ".mysql_error());
while (list($table, $name) = each($tbl)){
$sql = “select * from $table”;
$result = mysql_query($sql)or die("There was an error sending your query: ".mysql_error());
echo “

$name

”;
while ($row = mysql_fetch_object($result)) { ?>

Rename Delete
<?php }}?> <?php if (isset($_POST['Submit'])) { $id = $_POST['id']; $Type = $_POST['T']; $Man = $_POST['M']; $Price = $_POST['P']; // mysql_select_db($db) or die ("Error Message: ".mysql_error()); switch ($_POST['check']) { case "a"; if $sql = "UPDATE tables SET type='$Type', manufacturer='$Man', price='$Price' WHERE ID='$id'"; mysql_query($sql)or die("There was an error sending your query: ".mysql_error()); echo "database updated"; break; case "b"; $sql = "delete from $key where id='$id'"; $result = mysql_query($sql)or die("There was an error sending your query: ".mysql_error()); break; default: echo ("
Please select."); }} ?>[/code]

as you can see i have a mysql database which i must update recently.
when opened the script shows all the information from all the tables and lets me to rename or delete rows. Now i want to make one SUBMIT button which will change multiple values
e.g. i want to rename something from cpu table and delete something from coolers table and then at the end press the submit button.
also can you tell if i’ve changed e.g. an information in cpu and mainboard tables how can i tell the script that i’ve changed exactly those tables, this concerns to this line
$sql = "UPDATE tables SET type=’$Type’ how can i assign a value to tables when changed smth in those tables
sorry for this kind of language i just can’t explain it better. If smth is not understood please ask

I’m sorry but I am having a hard time understanding 1) what you are trying to do 2) the code itself 3) your english (smth = something?).

Please format your code using indentions. It is good programming style and will allow a reader to follow the logic.

I understand that you have a mysql database that you wish to be able to update by means of a form. You wish to update multiple values in the table - do you wish to update multiple tables and multiple rows in individual tables with 1 submit button? And the last part I don’t get at all.

ok here is the code
these are the tables that are in ‘price’ database

[code]<?php
$host = “localhost”;
$login = “”;
$pswd = “”;
$db = “price”;
$tbl = array(
“cpu”=>“Processor”,
“mb”=>“Mainboard”,
“pc_case”=>“PC Case”,
“memory”=>“Memory”,
“storage”=>“Storage”,
“video”=>“Video Card”,
“pc_card”=>“PC Card”,
“tv_recv”=>“TV Receiver”,
“sat_dish_acc”=>“Satellite Dish & Accessories”,
“cooler”=>“Cooler”,
“monitor”=>“Monitor”,
“printer”=>“Printer”,
“scanner”=>“Scanner”,
“modem”=>“Modem”,
“lan”=>“LAN”,
“hub”=>“HUB”,
“speaker”=>“Speaker”,
“mouse_keyb”=>“Mouse & Keyboard”,
“surge_arrest”=>“Surge Arrest”);

$con = mysql_connect($host, $login, $pswd) or die ("Error Message: ".mysql_error());
mysql_select_db($db) or die ("Error Message: ".mysql_error());[/code]
here i am jumping to all these tables and names and creating a form for every table.

[code]
while (list($table, $name) = each($tbl)){
$sql = “select * from $table”;
$result = mysql_query($sql)or die("There was an error sending your query: ".mysql_error());
echo “

$name

”;
while ($row = mysql_fetch_object($result)) { ?>

Delete
<?php }}?> <?php if (isset($_POST['Submit'])) { $id = $_POST['id']; $Type = $_POST['T']; $Man = $_POST['M']; $Price = $_POST['P']; switch ($_POST['check']) { case "a"; $sql = "delete from $key where id='$id'"; $result = mysql_query($sql)or die("There was an error sending your query: ".mysql_error()); echo "database updated"; break; default: $sql = "UPDATE SET type='$Type', manufacturer='$Man', price='$Price' WHERE ID='$id'"; mysql_query($sql)or die("There was an error sending your query: ".mysql_error()); echo "database updated"; }} ?>[/code] So here is how it works (p.s. i've changed the code a little bit) I have a price list which i must update recently and i don't want to upload the price.html file every time and i've decided to make a mysql database from which the price.php file will get all the info, but that's not the point,now i just want to make a simple form from where i want to change or delete some rows from tables. the last thing you've said is exactly the way i wanted to do ' do you wish to update multiple tables and multiple rows in individual tables with 1 submit button? And the last part I don't get at all.' -yes, and i don't know how to do that how to make every value to be inserted in it's own table p.s. smth=something! right. :-) thanks for your reply
Sponsor our Newsletter | Privacy Policy | Terms of Service