I have an idea and wonder if it can be or not on PHP since I'm new to PHP. I need to ping selected computer name or IP address and give me the status on ping status box as online or offline.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<title>Books</title>
</head>
<body>
<form action="Untitled-1.php" method="post">
<input type="text" name="search"/>
<input type="submit" value="search"/>
<input type="button"value="ping"/>
</form>
</form>
<br/>
<table border="1">
<thead>
<tr>
<th>username</th>
<th>desktop</th>
<th>ip address</th>
<th>select pc's</th>
<th>ping status</th>
</tr>
</thead>
<?php
include("db.php");
$word = isset ($_POST['search']) ? $_POST['search'] : "";
$result=mysql_query("SELECT * FROM pc WHERE desktop like '%$word%'");
while($test = mysql_fetch_array($result)) {
$id = $test['user_id'];
?>
<tr align='center'>
<td><font color='black'><?php echo $test['username'] ?></font></td>
<td><font color='black'><?php echo $test['desktop'] ?> </font></td>
<td><font color='black'><?php echo $test['ip_address'] ?></font></td>
<td><input name="selector[]" type="checkbox" value="<?php echo $id; ?>"></td>
<td><font color='black'><?php echo $test['ping_status'] ?></font></td>
</tr>
<?php
}
?>
</table>
</body>
</html>
please help
Pass ip in this function it give status of host.
<?php
function ping_host($host){
exec("ping -c 4 " . $host, $output, $result);
return $result==0?"online":"offline";
}
echo ping("www.google.com"); // function call
?>
Note:Here 4 is number of ping you want you can change according to requirement in linux system if you not set this it will ping forever.
thanks alot Sunil for try to help me , i found the selution and it's work fine with me now
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<?php
require("db.php");
?>
<body>
<form method="post">
<table cellpadding="0" cellspacing="0" border="1" class="table table-striped table-bordered" id="example">
<div class="alert alert-info">
<strong><i class="icon-user icon-large"></i></strong>
</div>
<thead>
<tr>
<th>username</th>
<th>desktop</th>
<th>ip address</th>
<th>select</th>
<th>status</th>
</tr>
</thead>
<tbody>
<?php
$query=mysql_query("select * from pc")or die(mysql_error());
while($row=mysql_fetch_array($query)){
$id=$row['ip_address'];
?>
<tr>
<td><?php echo $row['username'] ?></td>
<td><?php echo $row['desktop'] ?></td>
<td><?php echo $row['ip_address'] ?></td>
<td>
<input name="selector[]" type="checkbox" value="<?php echo $id; ?>"> </td>
<td><?php echo $row['ping_status'] ?></td>
</tr>
<?php }
if (isset($_POST['submit'])){
if(!empty($_POST['selector'])){
foreach($_POST['selector'] as $id){
if (!$socket = #fsockopen($id, 80, $errno, $errstr, 30))
{ $status= "offline";
echo $status; }
else
{ $status= "online";
echo $status;
fclose($socket); }
$sql="UPDATE pc SET ping_status='$status' WHERE ip_address='$id'";
$query=mysql_query($sql);
header("Location:test.php");
}
}
}
?>
</tbody>
</table>
<button class="btn btn-success" name="submit" type="submit">
ping
</button>
</form>
</body>
</html>
please find the last solution ,
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<?php
require("db.php");
?>
<body>
<form method="post">
<table cellpadding="0" cellspacing="0" border="1" class="table table-striped table-bordered" id="example">
<div class="alert alert-info">
<strong><i class="icon-user icon-large"></i></strong>
</div>
<thead>
<tr>
<th>username</th>
<th>desktop</th>
<th>ip address</th>
<th>select</th>
<th>status</th>
</tr>
</thead>
<tbody>
<?php
$query=mysql_query("select * from pc")or die(mysql_error());
while($row=mysql_fetch_array($query)){
$id=$row['ip_address'];
?>
<tr>
<td><?php echo $row['username'] ?></td>
<td><?php echo $row['desktop'] ?></td>
<td><?php echo $row['ip_address'] ?></td>
<td>
<input name="selector[]" type="checkbox" value="<?php echo $id; ?>"> </td>
<td><?php echo $row['ping_status'] ?></td>
</tr>
<?php }
$sql1="UPDATE pc
SET ping_status = NULL
WHERE ping_status is not null";
$query1=mysql_query($sql1);
function pingAddress($id) {
$pingresult = exec("ping -n 1 $id && exit", $output, $result);
//echo $result. "<br/>";
global $status;
if (($result == 0)){
if(count(preg_grep('/Destination host unreachable/i', $output)) == 0){
$status="online <br/>";
echo $status;
}else
$status="offline <br/>";
echo $status;
}
elseif ($result == 1){
$status="offline <br/>";
echo $status;
}
}
if (isset($_POST['submit'])){
if(!empty($_POST['selector'])){
foreach($_POST['selector'] as $id){
echo $id."";
pingAddress($id);
$sql="UPDATE pc SET ping_status='$status' WHERE ip_address='$id'";
$query=mysql_query($sql);
header("Location:test.php");
}
}
}
?>
</tbody>
</table>
<button class="btn btn-success" name="submit" type="submit">
ping
</button>
</form>
</body>
</html>
Related
The first row of this table is shown correctly and centered, while the other rows look like they are just being echo'd out instead of looking like they are part of the table.
This is the part of my code:
<table style="width:20%">
<tr>
<th>ID</th>
<th>Nume</th>
<th>Prenume</th>
</tr>
//fetching data from database
<tr>
<td><?php echo $data['id'];?></td>
<td><?php echo $data['nume'];?></td>
<td><?php echo $data['prenume'];?></td>
</tr>
</table>
The code is supposed to add the written user to a database and display all of the users in a table next to it.
Any help is appreciated! Thanks!
(whole code listed below)
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form action="index.php" method="post">
<input type="text" name="nume" placeholder="nume" required>
<input type="text" name="prenume" placeholder="prenume" required>
<input type="submit" name="sub" value="Adauga in baza de date">
<br>
</form>
<table style="width:20%">
<tr>
<th>ID</th>
<th>Nume</th>
<th>Prenume</th>
</tr>
<?php
if(isset($_POST['sub']))
{
$pdo = new PDO("mysql:host=localhost;dbname=liamed", "root", "");
$nume = $_POST['nume'];
$prenume = $_POST['prenume'];
$q = "insert into users(nume,prenume)values(:nume,:prenume)";
$r = $pdo->prepare($q);
$r->execute(array(":nume"=>$nume, ":prenume"=>$prenume));
}
$pdo = new PDO("mysql:host=localhost;dbname=liamed", "root", "");
$query = "select * from liamed.users";
$d = $pdo->query($query);
foreach ($d as $data){
?>
<tr>
<td><?php echo $data['id'];?></td>
<td><?php echo $data['nume'];?></td>
<td><?php echo $data['prenume'];?></td>
</tr>
</table>
</body>
<?php }
?>
</html>
You have the end of the table HTML included inside your loop hense the mess. Move that outside the loop and you should be sorted :)
foreach ($d as $data) :
?>
<tr>
<td><?php echo $data['id'];?></td>
<td><?php echo $data['nume'];?></td>
<td><?php echo $data['prenume'];?></td>
</tr>
<?php
endforeach;
?>
</table>
</body>
I want to update record in php using GET method but whenever i click on "update button" it does not change anything and just refresh the page.and data remains the same.Here are the codes. Kindly tell me where i m doing it wrong. Thanks
<?php
include_once"dbconfig.php";
if(isset($_GET['edit']))
{
$id=$_GET['edit'];
echo $id;
$sql_query="SELECT * FROM users WHERE user_id='$id' ";
$result_set=mysql_query($sql_query);
$fetched_row=mysql_fetch_array($result_set);
}
if(isset($_POST['btn-update']))
{
// variables for input data
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$city_name=$_POST['city_name'];
//sql query to update into database
$sql_query="UPDATE users SET first_name='$first_name',last_name='$last_name',user_city='$city_name' WHERE user_id='$id' ";
mysql_query($sql_query);
//if(!$sql_query)
//die('data can not update'.mysql_error());
//else
//echo 'data updated successfully';
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<center>
<form method="post">
<table align="center">
<tr>
<td><input type="text" name="first_name" placeholder="First Name" value="<?php echo $fetched_row['first_name']; ?>"required /> </td>
</tr>
<tr>
<td><input type="text" name="last_name" placeholder="Last Name" value="<?php echo $fetched_row['last_name']; ?>" required /> </td>
</tr>
<tr>
<td><input type="text" name="city_name" placeholder="City" value="<?php echo $fetched_row['user_city']; ?>" required /> </td>
</tr>
<tr>
<td>
<button type="submit" name="btn-update"><strong>UPDATE</strong></button>
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
Second File
<?php
include_once"dbconfig.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>CRUD Operations With php and MySql </title>
<link rel="stylesheet" href="style.css" type="text/css"/>
</head>
<body>
<center>
<div id="body">
<div id="content">
<table align="center">
<table align="center">
<tr>
<th colspan="9">Add data Here ! </th>
</tr>
<tr>
<th colspan="2">FirstName </th>
<th colspan="8">LastName</th>
<th colspan="4">CityName </th>
<th>Operations</th>
<!--<th colspan="2">Operations</th> -->
</tr>
<?php
$sql_query="SELECT * FROM users";
$result_set=mysql_query($sql_query);
while($row=mysql_fetch_row($result_set))
{
?>
<tr>
<td><?php echo $row[0]; ?> </td>
<td colspan="4"><?php echo $row[1]; ?></td>
<td colspan="6"><?php echo $row[2];?></td>
<td colspan="4"><?php echo $row[3];?></td>
<td> <a href='edit_data.php?edit=$row[0]'>EDIT</a> </td>
<!--<td align="center"><a href="javascript edt_id('<//?php echo $row[0]; ?><img src="b_edit.png" align="EDIT" /></a></td>
<td align="center"><a href="javascript:delete_id('<//?php echo $row[0];?><img src="b_drop.png" align="DELETE" /></a></td>
</tr> -->
<?php
}
?>
</table>
</div>
</div>
</center>
</body>
</html>
Change
mysql_query($sql_query);
To
mysql_query($sql_query) or die (mysql_error()) ;
You're not sending the id (the form action property is missing
I made a Student Result page. I wanted to export the results to excel. For that I made excel.php. When I click on the export button it is showing that there is no results. But results are showing in the webpage. Please find the attached screenshot of results and help me to solve the issue.
rsltmng.php
<?php
error_reporting(0);
session_start();
include_once '../oesdb.php';
/************************** Step 1 *************************/
if(!isset($_SESSION['admname'])) {
$_GLOBALS['message']="Session Timeout.Click here to Re-LogIn";
}
else if(isset($_REQUEST['logout'])) {
/************************** Step 2 - Case 1 *************************/
//Log out and redirect login page
unset($_SESSION['admname']);
header('Location: index.php');
}
else if(isset($_REQUEST['dashboard'])) {
/************************** Step 2 - Case 2 *************************/
//redirect to dashboard
header('Location: admwelcome.php');
}
else if(isset($_REQUEST['back'])) {
/************************** Step 2 - Case 3s *************************/
//redirect to Result Management
header('Location: rsltmng.php');
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<title>Manage Results - OES</title>
</head>
<body>
<div id="logmsk" style="display: block;">
<?php include("header.php"); ?>
<div id="page3">
<form name="rsltmng" action="rsltmng.php" method="post">
<div id="navigationbar">
<?php if(isset($_SESSION['admname'])) {
// Navigations
?>
<li><input type="submit" value="Logout" name="logout" class="aclass2" title="Log Out"/></li>
<?php if(isset($_REQUEST['testid'])) { ?>
<li><input type="submit" value="Back" name="back" class="aclass2" title="Manage Results"/></li>
<?php }else { ?>
<li><input type="submit" value="DashBoard" name="dashboard" class="aclass3" title="Dash Board"/></li>
<?php } ?>
</div>
<div><p style="font-weight:bold; color:#F00; text-align:center"><?php if($_GLOBALS['message']){ echo ($_GLOBALS['message']);}?></p></div>
<?php
if(isset($_REQUEST['testid'])) {
/************************** Step 3 - Case 1 *************************/
// Defualt Mode: Displays the Detailed Test Results.
$result=executeQuery("select t.testname,DATE_FORMAT(t.testfrom,'%d %M %Y') as fromdate,DATE_FORMAT(t.testto,'%d %M %Y %H:%i:%S') as todate,sub.subname,IFNULL((select sum(marks) from question where testid=".$_REQUEST['testid']."),0) as maxmarks from test as t, subject as sub where sub.subid=t.subid and t.testid=".$_REQUEST['testid'].";") ;
if(mysql_num_rows($result)!=0) {
$r=mysql_fetch_array($result);
?>
<table cellpadding="5" cellspacing="10" border="0" align="center" style="background:#ffffff url(../images/page.gif);text-align:left;line-height:20px;">
<tr>
<td colspan="2"><h3 style="color:#0000cc;text-align:center;"><u>Test Summary</u></h3></td>
</tr>
<!-- <tr>
<td colspan="2" ><hr style="color:#ff0000;border-width:4px;"/></td>
</tr>-->
<tr>
<td>Test Name:</td>
<td><b><?php echo htmlspecialchars_decode($r['testname'],ENT_QUOTES); ?></b></td>
</tr>
<tr>
<td>Subject Name:</td>
<td><b><?php echo htmlspecialchars_decode($r['subname'],ENT_QUOTES); ?></b></td>
</tr>
<tr>
<td>Validity:</td>
<td><b><?php echo $r['fromdate']." To ".$r['todate']; ?></b></td>
</tr>
<tr>
<td>Max. Marks:</td>
<td><b><?php echo $r['maxmarks']; ?></b></td>
</tr>
<tr><td colspan="2"><hr style="color:#ff0000;border-width:2px;"/></td></tr>
<!--<tr>
<td colspan="2"><h3 style="color:#0000cc;text-align:center;">Attempted Students</h3></td>
</tr>
<tr>
<td colspan="2" ><hr style="color:#ff0000;border-width:4px;"/></td>
</tr>-->
</table>
<table><tr><td><h3 style="color:#0000cc;text-align:center;"><u>Attempted Students</u></h3></td></tr></table>
<?php
$result1=executeQuery("select s.fname,s.contactno,s.emailid,IFNULL((select sum(q.marks) as om from studentquestion as sq, question as q where sq.testid=q.testid and sq.qnid=q.qnid and sq.answered='answered' and sq.stdanswer=q.correctanswer and sq.stdid=st.stdid and sq.testid=".$_REQUEST['testid']." order by sq.testid),0) as om from studenttest as st, student as s where s.stdid=st.stdid and st.testid=".$_REQUEST['testid']." order by om DESC;" );
if(mysql_num_rows($result1)==0) {
echo"<h3 style=\"color:#0000cc;text-align:center;\">No Students Yet Attempted this Test!</h3>";
}
else {
?>
<table cellpadding="5" cellspacing="10" class="datatable">
<tr>
<th>Student Name</th>
<th>Contact Number</th>
<th>Email-ID</th>
<th>Obtained Marks</th>
<th>Result(%)</th>
</tr>
<?php
while($r1=mysql_fetch_array($result1)) {
?>
<tr>
<td><?php echo htmlspecialchars_decode($r1['fname'],ENT_QUOTES); ?></td>
<td><?php echo htmlspecialchars_decode($r1['contactno'],ENT_QUOTES); ?></td>
<td><?php echo htmlspecialchars_decode($r1['emailid'],ENT_QUOTES); ?></td>
<td><?php echo $r1['om']; ?></td>
<td><?php echo ($r1['om']/$r['maxmarks']*100)." %"; ?></td>
</tr>
<form method="post" action="excel.php"><input type="submit" name="export_excel" class="aclass3" value="Export Result" /></form>
<?php
}
}
}
else {
echo"<h3 style=\"color:#0000cc;text-align:center;\">Something went wrong. Please logout and Try again.</h3>";
}
?>
</table>
<?php
}
else {
/************************** Step 3 - Case 2 *************************/
// Defualt Mode: Displays the Test Results.
$result=executeQuery("select t.testid,t.testname,DATE_FORMAT(t.testfrom,'%d %M %Y') as fromdate,DATE_FORMAT(t.testto,'%d %M %Y %H:%i:%S') as todate,sub.subname,(select count(stdid) from studenttest where testid=t.testid) as attemptedstudents from test as t, subject as sub where sub.subid=t.subid;");
if(mysql_num_rows($result)==0) {
echo "<h3 style=\"color:#0000cc;text-align:center;\">No Tests Yet...!</h3>";
}
else {
$i=0;
?>
<table cellpadding="10" cellspacing="10" class="datatable">
<tr>
<th>Test Name</th>
<th>Validity</th>
<th>Subject Name</th>
<th>Attempted Students</th>
<th>Details</th>
</tr>
<?php
while($r=mysql_fetch_array($result)) {
$i=$i+1;
if($i%2==0) {
echo "<tr class=\"alt\">";
}
else { echo "<tr>";}
echo "<td>".htmlspecialchars_decode($r['testname'],ENT_QUOTES)."</td><td>".$r['fromdate']." To ".$r['todate']." PM </td>"
."<td>".htmlspecialchars_decode($r['subname'],ENT_QUOTES)."</td><td>".$r['attemptedstudents']."</td>"
."<td class=\"tddata\"><a title=\"Details\" href=\"rsltmng.php?testid=".$r['testid']."\"><img src=\"../images/detail.png\" height=\"30\" width=\"40\" alt=\"Details\" /></a></td></tr>";
}
?>
</table>
<?php
}
}
closedb();
}
?>
</form>
</div>
<div style="position: relative; clear:both; z-index:10; height:3em; margin-top:-3em"><?php include("footer.php"); ?></div>
</div>
</body>
</html>
excel.php
<?php
$connect = mysqli_connect("localhost", "root", "", "ssmc_ae_drsunny");
$output = '';
$_REQUEST['testid']=isset($_REQUEST['testid']);
if(isset($_POST["export_excel"]))
{
$sql=executeQuery("select s.fname,s.contactno,s.emailid,IFNULL((select sum(q.marks) as om from studentquestion as sq, question as q where sq.testid=q.testid and sq.qnid=q.qnid and sq.answered='answered' and sq.stdanswer=q.correctanswer and sq.stdid=st.stdid and sq.testid=".$_REQUEST['testid']." order by sq.testid),0) as om from studenttest as st, student as s where s.stdid=st.stdid and st.testid=".$_REQUEST['testid']." order by om DESC;" );
$result=mysqli_query($connect, $sql);
if(mysqli_num_rows($result)>0)
{
$output .= '
<table cellpadding="5" cellspacing="10" class="datatable">
<tr>
<th>Student Name</th>
<th>Contact Number</th>
<th>Email-ID</th>
<th>Obtained Marks</th>
<th>Result(%)</th>
</tr>
';
while ($row=mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row['fname'].'</td>
<td>'.$row['contactno'].'</td>
<td>'.$row['emailid'].'</td>
<td>'.$row['om'].'</td>
<td>'.$row['om'].'/'.$row['maxmarks'].'*100."%"</td>
</tr>
';
}
$output .= '</table>';
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=download.xls");
echo $output;
}
else
{echo "NO RESULT"; }
}
?>
$_REQUEST['testid']=isset($_REQUEST['testid']);
This line actually makes the $_REQUEST['testid'] variable into 1 or 0.
So the query gets executed but no result gets displayed as there is no such row int the table.
I am trying to create a page that displays rpg ranks from a mysql database on a webpage
i went into the database and organized the data by level, so the person with the highest level is shown first and so on, however the database does not contain a table for ranks
I am trying to do that manually in dreamweaver but I don't know how, can I create a counter and have it display in the table?
I managed to get the following:
http://slayersgaming.com/rpgranks2.php
<?php
$dbh=mysql_connect("********", "**********", "*********") or die('Cannot connect to the database because: '. mysql_error());
mysql_select_db("C368969_thcrpgCSGO");
$rpgranks_sql = "SELECT * FROM `thc_rpg` ORDER BY `thc_rpg`.`level` DESC LIMIT 0, 30 ";
$rpgranks_query = mysql_query($rpgranks_sql) or die(mysql_error());
$rsrpgranks = mysql_fetch_assoc($rpgranks_query);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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>
<p>
<table width="501" height="58" border="0">
<tr>
<td width="240"><h2><strong>Name</strong></h2></td>
<td width="70"><strong>Level</strong></td>
<td width="70"><strong>XP</strong></td>
<td width="70"><strong>Credits</strong></td>
<td width="70"><strong>Rank</strong></td>
</tr>
</table>
<?php do{ ?>
<table width="501" height="58" border="0">
<tr>
<td width="240"><?php echo $rsrpgranks['name'];?></td>
<td width="70"><?php echo $rsrpgranks['level'];?></td>
<td width="70"><?php echo $rsrpgranks['xp'];?></td>
<td width="70"><?php echo $rsrpgranks['credits'];?></td>
<td width="70"> </td>
</tr>
</table>
<?php } while ($rsrpgranks = mysql_fetch_assoc($rpgranks_query)) ?>
</p>
<p> </p>
</body>
</html>
screen cap here: http://oi47.tinypic.com/21exdfs.jpg
This is actually really easy to do. You just need a counter in your do-while loop like this:
<?php
$counter = 1;
do{
?>
<table width="501" height="58" border="0">
<tr>
<td><?php echo $counter; ?></td>
<td width="240"><?php echo $rsrpgranks['name'];?></td>
<td width="70"><?php echo $rsrpgranks['level'];?></td>
<td width="70"><?php echo $rsrpgranks['xp'];?></td>
<td width="70"><?php echo $rsrpgranks['credits'];?></td>
<td width="70"> </td>
</tr>
</table>
<?php
$counter++;
} while ($rsrpgranks = mysql_fetch_assoc($rpgranks_query))
?>
i have this code:
<?php
////////////////////////////////////////
include "../includes/site_includes.php";//
//////////////////////////////////////
$sql = getallsitesettings();
if ($result = $mysqli->prepare($sql))
{
$rekza = 1;
$result->bind_param("i",$rekza);
$result->execute();
$result->store_result();
$rowsZ = $result->num_rows;
}
if($rowsZ>0)
{
$row = fetch($result);
}
$siteTitle= $row[0]["site_title"];
$sitePeleText= $row[0]["pele"];
?>
<?php
$act = $mysqli->real_escape_string($_GET["act"]);
if($act=="edit")
{
$folderid = (int)$_GET["id"];
$sql2 = getfolderbyId();
if ($result2 = $mysqli->prepare($sql2))
{
$result2->bind_param("i",$folderid);
$result2->execute();
$result2->store_result();
$rowsZ2 = $result2->num_rows;
}
if($rowsZ2>0)
{
$row2 = fetch($result2);
}
for($j=0; $j<$rowsZ2; $j++)
{
$foldername = $row2[$j]["fold_name"];
$foldpath = $row2[$j]["fold_path"];
$foldpic = $row2[$j]["fold_pic"];
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html dir="rtl">
<head>
<title><?=$txt_folders?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<link href="<?=$site_url?>/css/styles.css" rel="stylesheet" type="text/css" />
</head>
<table align="center" cellspacing="0" cellpadding="0" width="1021">
<tr>
<td><?php
include "../site_header.php";
?></td>
</tr>
<tr>
<td style="background-color:#dcdbdb;">
<table align="center" cellspacing="0" cellpadding="0" width="1021">
<tr>
<td>
<div class="admintitle">
<?=$txt_main_admin?> > <?=$txt_folders?>
</div>
</td>
</tr>
<tr>
<td>
<table align="center" cellspacing="0" cellpadding="0" width="400">
<tr>
<td style="color:Black; font-family:arial; font-weight:Bold;"><?=$txt_folders_name?></td>
<td style="color:Black; font-family:arial; font-weight:normal;"><input type="textbox" name="fold_name" value="<?=$foldername?>" /></td>
</tr>
<tr>
<td style="color:Black; font-family:arial; font-weight:Bold;"><?=$txt_folder_path?></td>
<td style="color:Black; font-family:arial; font-weight:normal;"><input type="textbox" name="fold_path" value="<?=$foldpath?>" /></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td><?php
include "../site_footer.php";
?></td>
</tr>
</table>
<body>
</body>
</html>
...
can you tell me whats the problem ?
why when act = add
the variables in value="" in the input is undefined?....and how can i define them in the edit and in the add...
in the add i need them empty...and in the edit it works great....
May be...
if($act=="edit" || $act=="add")
:)