[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.5

php code modification for mysql from oracle

Asked by karunamoorthy in PHP Scripting Language

Tags: php mysql

I have a sample php page which is working fine with PHP+Oracle environment. Now I have to modify this code to work in mysql environment. I am new(novice) to mysql and php. Anyone help me to change this code to work in mysql.

Thanks in advance.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:
500:
501:
502:
503:
504:
505:
506:
507:
508:
509:
510:
511:
512:
513:
514:
515:
516:
517:
518:
519:
520:
521:
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543:
544:
545:
546:
547:
548:
549:
550:
551:
552:
553:
554:
555:
556:
557:
558:
559:
560:
561:
562:
563:
564:
565:
566:
567:
568:
569:
570:
571:
572:
573:
574:
575:
576:
577:
578:
579:
580:
581:
582:
583:
584:
585:
586:
587:
588:
589:
590:
591:
592:
593:
594:
595:
596:
597:
598:
599:
600:
601:
602:
603:
604:
605:
606:
607:
608:
609:
610:
611:
612:
613:
614:
615:
616:
617:
618:
619:
620:
621:
622:
623:
624:
625:
626:
627:
628:
629:
630:
631:
632:
633:
634:
635:
636:
637:
638:
639:
640:
641:
642:
643:
644:
645:
646:
647:
648:
649:
650:
651:
652:
653:
654:
655:
656:
657:
658:
659:
660:
661:
662:
663:
664:
665:
666:
667:
668:
669:
670:
671:
672:
673:
674:
675:
676:
677:
678:
679:
680:
681:
682:
683:
684:
685:
686:
687:
688:
689:
690:
691:
692:
693:
694:
695:
696:
697:
698:
699:
700:
701:
702:
703:
704:
705:
706:
707:
708:
709:
710:
711:
712:
713:
714:
715:
716:
717:
718:
719:
720:
721:
722:
723:
724:
725:
726:
727:
728:
729:
730:
731:
732:
733:
734:
735:
736:
737:
738:
<? session_start(); ?>
 
<html>
<head>
<title>MY CONTACTS</title>
<meta name="generator" http-equiv="content-type" content="text/html">
<style type="text/css">
  body {
    background-color: #FFFFFF;
    color: #004080;
    font-family: Arial;
    font-size: 12px;
  }
  .bd {
    background-color: #FFFFFF;
    color: #004080;
    font-family: Arial;
    font-size: 12px;
  }
  .tbl {
    background-color: #FFFFFF;
  }
  a:link { 
    color: #FF0000;
    font-family: Arial;
    font-size: 12px;
  }
  a:active { 
    color: #0000FF;
    font-family: Arial;
    font-size: 12px;
  }
  a:visited { 
    color: #800080;
    font-family: Arial;
    font-size: 12px;
  }
  .hr {
    background-color: #336699;
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:link {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:active {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  a.hr:visited {
    color: #FFFFFF;
    font-family: Arial;
    font-size: 12px;
  }
  .dr {
    background-color: #FFFFFF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
  .sr {
    background-color: #EFEFEF;
    color: #000000;
    font-family: Arial;
    font-size: 12px;
  }
</style>
</head>
<body>
<table class="bd" width="100%"><tr><td class="hr"><h2>My Contacts</h2></td></tr></table>
<?php
  if (!login()) exit;
?>
<?php
  $conn = connect();
  $showrecs = 50;
  $pagerange = 10;
 
  $a = @$_GET["a"];
  $recid = @$_GET["recid"];
  if (isset($_GET["order"])) $order = @$_GET["order"];
  if (isset($_GET["type"])) $ordtype = @$_GET["type"];
 
  if (isset($_POST["filter"])) $filter = @$_POST["filter"];
  if (isset($_POST["filter_field"])) $filterfield = @$_POST["filter_field"];
  $wholeonly = false;
  if (isset($_POST["wholeonly"])) $wholeonly = @$_POST["wholeonly"];
 
  if (!isset($order) && isset($_SESSION["order"])) $order = $_SESSION["order"];
  if (!isset($ordtype) && isset($_SESSION["type"])) $ordtype = $_SESSION["type"];
  if (!isset($filter) && isset($_SESSION["filter"])) $filter = $_SESSION["filter"];
  if (!isset($filterfield) && isset($_SESSION["filter_field"])) $filterfield = $_SESSION["filter_field"];
 
  $page = @$_GET["page"];
  if (!isset($page)) $page = 1;
 
  $sql = @$_POST["sql"];
 
  switch ($sql) {
    case "insert":
      sql_insert();
      break;
    case "update":
      sql_update();
      break;
    case "delete":
      sql_delete();
      break;
    case "copy":
      sql_copy();
      break;
 
  }
 
  switch ($a) {
    case "add":
      addrec();
      break;
    case "copy":
      copyrec($recid);
      break;
    case "view":
      viewrec($recid);
      break;
    case "edit":
      editrec($recid);
      break;
    case "del":
      deleterec($recid);
      break;
    default:
      select();
      break;
  }
 
  if (isset($order)) $_SESSION["order"] = $order;
  if (isset($ordtype)) $_SESSION["type"] = $ordtype;
  if (isset($filter)) $_SESSION["filter"] = $filter;
  if (isset($filterfield)) $_SESSION["filter_field"] = $filterfield;
  if (isset($wholeonly)) $_SESSION["wholeonly"] = $wholeonly;
 
  ocilogoff($conn);
?>
<table class="bd" width="100%"><tr><td class="hr">My Contacts</td></tr></table>
</body>
</html>
 
<?php function select()
  {
  global $a;
  global $showrecs;
  global $page;
  global $filter;
  global $filterfield;
  global $wholeonly;
  global $order;
  global $ordtype;
 
 
  if ($a == "reset") {
    $filter = "";
    $filterfield = "";
    $wholeonly = "";
    $order = "";
    $ordtype = "";
  }
 
  $checkstr = "";
  if ($wholeonly) $checkstr = " checked";
  if ($ordtype == "asc") { $ordtypestr = "desc"; } else { $ordtypestr = "asc"; }
  $res = sql_select();
  $count = sql_getrecordcount();
  if ($count % $showrecs != 0) {
    $pagecount = intval($count / $showrecs) + 1;
  }
  else {
    $pagecount = intval($count / $showrecs);
  }
  $startrec = $showrecs * ($page - 1);
  if ($startrec < $count) {for ($i = 1; $i <= $startrec; ocifetchassoc($res), $i++);}
  $reccount = min($showrecs * $page, $count);
  $fields = array(
    "NAME" => "NAME",
    "CELLNO" => "CELLNO",
    "DESIGNATION" => "DESIGNATION",
    "OFFICE" => "OFFICE",
    "EMAILID" => "EMAILID",
    "ADDRESS" => "ADDRESS",
    "REMARKS" => "REMARKS");
?>
<div style="float: right"><a href="contacts.php?a=logout">[ Logout ]</a></div>
 
<table class="bd" border="0" cellspacing="1" cellpadding="4">
 
<tr><td>Records shown <?php echo $startrec + 1 ?> - <?php echo $reccount ?> of <?php echo $count ?></td></tr>
</table>
<form action="contacts.php" method="post">
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><b>Custom Filter</b>&nbsp;</td>
<td><input type="text" name="filter" value="<?php echo $filter ?>"></td>
<td><select name="filter_field">
<option value="">All Fields</option>
<?php
  reset($fields);
  foreach($fields as $val => $caption) {
    if ($val == $filterfield) {$selstr = " selected"; } else {$selstr = ""; }
?>
<option value="<?php echo $val ?>"<?php echo $selstr ?>><?php echo htmlspecialchars($caption) ?></option>
<?php } ?>
</select></td>
<td><input type="checkbox" name="wholeonly"<?php echo $checkstr ?>>Whole words only</td>
</td></tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="action" value="Apply Filter"></td>
<td><a href="contacts.php?a=reset">Reset Filter</a></td>
</tr>
</table>
</form>
 
<?php showpagenav($page, $pagecount); ?>
<br>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="100%">
<tr>
<?php
  reset($fields);
  foreach($fields as $val => $caption) {
?>
<td class="hr"><a class="hr" href="contacts.php?order=<?php echo $val ?>&type=<?php echo $ordtypestr ?>"><?php echo htmlspecialchars($caption) ?></a></td>
<?php } ?>
<td class="hr">Copy</td>
<td class="hr">View</td>
<td class="hr">Edit</td>
<td class="hr">Delete</td>
</tr>
<?php
  for ($i = $startrec; $i < $reccount; $i++)
  {
    $row = ocifetchassoc($res);
    $style = "dr";
    if ($i % 2 != 0) {
      $style = "sr";
    }
?>
<tr>
<?php
  reset($fields);
  foreach($fields as $val => $caption) {
?>
<td class="<?php echo $style ?>"><?php echo htmlspecialchars($row[$val]) ?></td>
<?php } ?>
<td class="<?php echo $style ?>"><a href="contacts.php?a=copy&recid=<?php echo $i ?>">Copy</a></td>
<td class="<?php echo $style ?>"><a href="contacts.php?a=view&recid=<?php echo $i ?>">View</a></td>
<td class="<?php echo $style ?>"><a href="contacts.php?a=edit&recid=<?php echo $i ?>">Edit</a></td>
<td class="<?php echo $style ?>"><a href="contacts.php?a=del&recid=<?php echo $i ?>">Delete</a></td>
</tr>
<?php
  }
  ocifreestatement($res);
?>
</table>
<br>
<?php showpagenav($page, $pagecount); ?>
<?php } ?>
 
<?php function login()
{
  global $_POST;
  global $_SESSION;
 
  global $_GET;
  if (isset($_GET["a"]) && ($_GET["a"] == 'logout')) $_SESSION["logged_in"] = false;
  if (!isset($_SESSION["logged_in"])) $_SESSION["logged_in"] = false;
  if (!$_SESSION["logged_in"]) {
    $login = "";
    $password = "";
    if (isset($_POST["login"])) $login = @$_POST["login"];
    if (isset($_POST["password"])) $password = @$_POST["password"];
 
    if (($login != "") && ($password != "")) {
      if (($login == "ppc") && ($password == "ppc")) {
        $_SESSION["logged_in"] = true;
    }
    else {
?>
<p><b><font color="-1">Sorry, the login/password combination you've entered is invalid</font></b></p>
<?php } } }if (isset($_SESSION["logged_in"]) && (!$_SESSION["logged_in"])) { ?>
<form action="contacts.php" method="post">
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td>Login</td>
<td><input type="text" name="login" value="<?php echo $login ?>"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" value="<?php echo $password ?>"></td>
</tr>
<tr>
<td><input type="submit" name="action" value="Login"></td>
</tr>
</table>
</form>
<?php
  }
  if (!isset($_SESSION["logged_in"])) $_SESSION["logged_in"] = false;
  return $_SESSION["logged_in"];
} ?>
 
<?php function showrow($row)
  {
?>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="50%">
<tr>
<td class="hr"><?php echo htmlspecialchars("NAME")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["NAME"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("CELLNO")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["CELLNO"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("DESIGNATION")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["DESIGNATION"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("OFFICE")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["OFFICE"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("EMAILID")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["EMAILID"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("ADDRESS")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["ADDRESS"]) ?></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("REMARKS")."&nbsp;" ?></td>
<td class="dr"><?php echo htmlspecialchars($row["REMARKS"]) ?></td>
</tr>
</table>
<?php } ?>
 
<?php function showroweditor($row)
  {
  global $conn;
?>
<table class="tbl" border="0" cellspacing="1" cellpadding="5"width="60%">
<tr>
<td class="hr"><?php echo htmlspecialchars("NAME")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="NAME" maxlength="25" value="<?php echo str_replace('"', '&quot;', trim($row["NAME"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("CELLNO")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="CELLNO" maxlength="25" value="<?php echo str_replace('"', '&quot;', trim($row["CELLNO"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("DESIGNATION")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="DESIGNATION" maxlength="25" value="<?php echo str_replace('"', '&quot;', trim($row["DESIGNATION"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("OFFICE")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="OFFICE" maxlength="25" value="<?php echo str_replace('"', '&quot;', trim($row["OFFICE"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("EMAILID")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="EMAILID" maxlength="30" value="<?php echo str_replace('"', '&quot;', trim($row["EMAILID"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("ADDRESS")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="ADDRESS" maxlength="50" value="<?php echo str_replace('"', '&quot;', trim($row["ADDRESS"])) ?>"></td>
</tr>
<tr>
<td class="hr"><?php echo htmlspecialchars("REMARKS")."&nbsp;" ?></td>
<td class="dr"><input type="text" name="REMARKS" maxlength="10" value="<?php echo str_replace('"', '&quot;', trim($row["REMARKS"])) ?>"></td>
</tr>
</table>
<?php } ?>
 
<?php function showpagenav($page, $pagecount)
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="contacts.php?a=add">Add Record</a>&nbsp;</td>
<?php if ($page > 1) { ?>
<td><a href="contacts.php?page=<?php echo $page - 1 ?>">&lt;&lt;&nbsp;Prev</a>&nbsp;</td>
<?php } ?>
<?php
  global $pagerange;
 
  if ($pagecount > 1) {
 
  if ($pagecount % $pagerange != 0) {
    $rangecount = intval($pagecount / $pagerange) + 1;
  }
  else {
    $rangecount = intval($pagecount / $pagerange);
  }
  for ($i = 1; $i < $rangecount + 1; $i++) {
    $startpage = (($i - 1) * $pagerange) + 1;
    $count = min($i * $pagerange, $pagecount);
 
    if ((($page >= $startpage) && ($page <= ($i * $pagerange)))) {
      for ($j = $startpage; $j < $count + 1; $j++) {
        if ($j == $page) {
?>
<td><b><?php echo $j ?></b></td>
<?php } else { ?>
<td><a href="contacts.php?page=<?php echo $j ?>"><?php echo $j ?></a></td>
<?php } } } else { ?>
<td><a href="contacts.php?page=<?php echo $startpage ?>"><?php echo $startpage ."..." .$count ?></a></td>
<?php } } } ?>
<?php if ($page < $pagecount) { ?>
<td>&nbsp;<a href="contacts.php?page=<?php echo $page + 1 ?>">Next&nbsp;&gt;&gt;</a>&nbsp;</td>
<?php } ?>
</tr>
</table>
<?php } ?>
 
<?php function showrecnav($a, $recid, $count)
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="contacts.php">Index Page</a></td>
<?php if ($recid > 0) { ?>
<td><a href="contacts.php?a=<?php echo $a ?>&recid=<?php echo $recid - 1 ?>">Prior Record</a></td>
<?php } if ($recid < $count - 1) { ?>
<td><a href="contacts.php?a=<?php echo $a ?>&recid=<?php echo $recid + 1 ?>">Next Record</a></td>
<?php } ?>
</tr>
</table>
<hr size="1" noshade>
<?php } ?>
 
<?php function addrec()
{
?>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="contacts.php">Index Page</a></td>
</tr>
</table>
<hr size="1" noshade>
<form action="contacts.php" method="post">
<p><input type="hidden" name="sql" value="insert"></p>
<?php
$row = array(
  "NAME" => "",
  "CELLNO" => "",
  "DESIGNATION" => "",
  "OFFICE" => "",
  "EMAILID" => "",
  "ADDRESS" => "",
  "REMARKS" => "");
showroweditor($row)
?>
<p><input type="submit" name="action" value="Post"></p>
</form>
<?php } ?>
 
<?php function copyrec($recid)
{
  $res = sql_select();
  $count = sql_getrecordcount();
  for ($i = 1; $i <= $recid; ocifetchassoc($res), $i++);
  $row = ocifetchassoc($res);
  showrecnav("copy", $recid, $count);
?>
 
 
<br>
<form action="contacts.php" method="post">
<input type="hidden" name="sql" value="insert">
<input type="hidden" name="xNAME" value="<?php echo $row["NAME"] ?>">
<input type="hidden" name="xCELLNO" value="<?php echo $row["CELLNO"] ?>">
<input type="hidden" name="xDESIGNATION" value="<?php echo $row["DESIGNATION"] ?>">
<input type="hidden" name="xOFFICE" value="<?php echo $row["OFFICE"] ?>">
<input type="hidden" name="xEMAILID" value="<?php echo $row["EMAILID"] ?>">
<input type="hidden" name="xADDRESS" value="<?php echo $row["ADDRESS"] ?>">
<input type="hidden" name="xREMARKS" value="<?php echo $row["REMARKS"] ?>">
<?php showroweditor($row) ?>
<p><input type="submit" name="action" value="Post"></p>
</form>
<?php
  ocifreestatement($res);
} ?>
 
<?php function viewrec($recid)
{
  $res = sql_select();
  $count = sql_getrecordcount();
  for ($i = 1; $i <= $recid; ocifetchassoc($res), $i++);
  $row = ocifetchassoc($res);
  showrecnav("view", $recid, $count);
?>
<br>
<?php showrow($row) ?>
<br>
<hr size="1" noshade>
<table class="bd" border="0" cellspacing="1" cellpadding="4">
<tr>
<td><a href="contacts.php?a=add">Add Record</a></td>
<td><a href="contacts.php?a=copy&recid=<?php echo $recid ?>">Copy Record</a></td>
<td><a href="contacts.php?a=edit&recid=<?php echo $recid ?>">Edit Record</a></td>
<td><a href="contacts.php?a=del&recid=<?php echo $recid ?>">Delete Record</a></td>
</tr>
</table>
<?php
  ocifreestatement($res);
} ?>
 
<?php function editrec($recid)
{
  $res = sql_select();
  $count = sql_getrecordcount();
  for ($i = 1; $i <= $recid; ocifetchassoc($res), $i++);
  $row = ocifetchassoc($res);
  showrecnav("edit", $recid, $count);
?>
 
 
<br>
<form action="contacts.php" method="post">
<input type="hidden" name="sql" value="update">
<input type="hidden" name="xNAME" value="<?php echo $row["NAME"] ?>">
<input type="hidden" name="xCELLNO" value="<?php echo $row["CELLNO"] ?>">
<input type="hidden" name="xDESIGNATION" value="<?php echo $row["DESIGNATION"] ?>">
<input type="hidden" name="xOFFICE" value="<?php echo $row["OFFICE"] ?>">
<input type="hidden" name="xEMAILID" value="<?php echo $row["EMAILID"] ?>">
<input type="hidden" name="xADDRESS" value="<?php echo $row["ADDRESS"] ?>">
<input type="hidden" name="xREMARKS" value="<?php echo $row["REMARKS"] ?>">
<?php showroweditor($row) ?>
<p><input type="submit" name="action" value="Post"></p>
</form>
<?php
  ocifreestatement($res);
} ?>
 
<?php function deleterec($recid)
{
  $res = sql_select();
  $count = sql_getrecordcount();
  for ($i = 1; $i <= $recid; ocifetchassoc($res), $i++);
  $row = ocifetchassoc($res);
  showrecnav("del", $recid, $count);
?>
<br>
<form action="contacts.php" method="post">
<input type="hidden" name="sql" value="delete">
<input type="hidden" name="xNAME" value="<?php echo $row["NAME"] ?>">
<input type="hidden" name="xCELLNO" value="<?php echo $row["CELLNO"] ?>">
<input type="hidden" name="xDESIGNATION" value="<?php echo $row["DESIGNATION"] ?>">
<input type="hidden" name="xOFFICE" value="<?php echo $row["OFFICE"] ?>">
<input type="hidden" name="xEMAILID" value="<?php echo $row["EMAILID"] ?>">
<input type="hidden" name="xADDRESS" value="<?php echo $row["ADDRESS"] ?>">
<input type="hidden" name="xREMARKS" value="<?php echo $row["REMARKS"] ?>">
<?php showrow($row) ?>
<p><input type="submit" name="action" value="Confirm"></p>
</form>
<?php
  ocifreestatement($res);
} ?>
 
<?php function connect()
{
  $conn = ocilogon("PPC", "ppc123", "payroll");
  return $conn;
}
 
function sqlvalue($val, $quote)
{
  if ($quote)
    $tmp = sqlstr($val);
  else
    $tmp = $val;
  if ($tmp == "")
    $tmp = "NULL";
  elseif ($quote)
    $tmp = "'".$tmp."'";
  return $tmp;
}
 
function sqlstr($val)
{
  return str_replace("'", "''", $val);
}
 
function sql_select()
{
  global $conn;
  global $order;
  global $ordtype;
  global $filter;
  global $filterfield;
  global $wholeonly;
 
  $filterstr = sqlstr($filter);
  if (!$wholeonly && isset($wholeonly) && $filterstr!='') $filterstr = "%" .$filterstr ."%";
  $sql = "SELECT \"NAME\", CELLNO, DESIGNATION, OFFICE, EMAILID, ADDRESS, REMARKS FROM PPC.TBL_CONTACTS";
  if (isset($filterstr) && $filterstr!='' && isset($filterfield) && $filterfield!='') {
    $sql .= " where " .sqlstr($filterfield) ." like '" .$filterstr ."'";
  } elseif (isset($filterstr) && $filterstr!='') {
    $sql .= " where (\"NAME\" like '" .$filterstr ."') or (CELLNO like '" .$filterstr ."') or (DESIGNATION like '" .$filterstr ."') or (OFFICE like '" .$filterstr ."') or (EMAILID like '" .$filterstr ."') or (ADDRESS like '" .$filterstr ."') or (REMARKS like '" .$filterstr ."')";
  }
  if (isset($order) && $order!='') $sql .= " order by \"" .sqlstr($order) ."\"";
  if (isset($ordtype) && $ordtype!='') $sql .= " " .sqlstr($ordtype);
  $res = ociquery($sql);
  return $res;
}
 
function sql_getrecordcount()
{
  global $conn;
  global $order;
  global $ordtype;
  global $filter;
  global $filterfield;
  global $wholeonly;
 
  $filterstr = sqlstr($filter);
  if (!$wholeonly && isset($wholeonly) && $filterstr!='') $filterstr = "%" .$filterstr ."%";
  $sql = "SELECT COUNT(*) FROM PPC.TBL_CONTACTS";
  if (isset($filterstr) && $filterstr!='' && isset($filterfield) && $filterfield!='') {
    $sql .= " where " .sqlstr($filterfield) ." like '" .$filterstr ."'";
  } elseif (isset($filterstr) && $filterstr!='') {
    $sql .= " where (\"NAME\" like '" .$filterstr ."') or (CELLNO like '" .$filterstr ."') or (DESIGNATION like '" .$filterstr ."') or (OFFICE like '" .$filterstr ."') or (EMAILID like '" .$filterstr ."') or (ADDRESS like '" .$filterstr ."') or (REMARKS like '" .$filterstr ."')";
  }
  $res = ociquery($sql);
  $row = ocifetchassoc($res);
  reset($row);
  return current($row);
}
 
function sql_insert()
{
  global $conn;
  global $_POST;
 
  $sql = "insert into PPC.TBL_CONTACTS (\"NAME\", CELLNO, DESIGNATION, OFFICE, EMAILID, ADDRESS, REMARKS) values (" .sqlvalue(@$_POST["NAME"], true) .", " .sqlvalue(@$_POST["CELLNO"], true) .", " .sqlvalue(@$_POST["DESIGNATION"], true) .", " .sqlvalue(@$_POST["OFFICE"], true) .", " .sqlvalue(@$_POST["EMAILID"], true) .", " .sqlvalue(@$_POST["ADDRESS"], true) .", " .sqlvalue(@$_POST["REMARKS"], true) .")";
  ociquery($sql);
}
 
function sql_update()
{
  global $conn;
  global $_POST;
 
  $sql = "update PPC.TBL_CONTACTS set \"NAME\"=" .sqlvalue(@$_POST["NAME"], true) .", CELLNO=" .sqlvalue(@$_POST["CELLNO"], true) .", DESIGNATION=" .sqlvalue(@$_POST["DESIGNATION"], true) .", OFFICE=" .sqlvalue(@$_POST["OFFICE"], true) .", EMAILID=" .sqlvalue(@$_POST["EMAILID"], true) .", ADDRESS=" .sqlvalue(@$_POST["ADDRESS"], true) .", REMARKS=" .sqlvalue(@$_POST["REMARKS"], true) ." where " .primarykeycondition();
  ociquery($sql);
}
 
function sql_delete()
{
  global $conn;
 
  $sql = "delete from PPC.TBL_CONTACTS where " .primarykeycondition();
  ociquery($sql);
}
function primarykeycondition()
{
  global $_POST;
  $pk = "";
  $pk .= "(\"NAME\"";
  if (@$_POST["xNAME"] == "") {
    $pk .= " IS NULL";
  }else{
  $pk .= " = " .sqlvalue(@$_POST["xNAME"], true);
  };
  $pk .= ") and ";
  $pk .= "(CELLNO";
  if (@$_POST["xCELLNO"] == "") {
    $pk .= " IS NULL";
  }else{
  $pk .= " = " .sqlvalue(@$_POST["xCELLNO"], true);
  };
  $pk .= ") and ";
  $pk .= "(DESIGNATION";
  if (@$_POST["xDESIGNATION"] == "") {
    $pk .= " IS NULL";
  }else{
  $pk .= " = " .sqlvalue(@$_POST["xDESIGNATION"], true);
  };
  $pk .= ") and ";
  $pk .= "(OFFICE";
  if (@$_POST["xOFFICE"] == "") {
    $pk .= " IS NULL";
  }else{
  $pk .= " = " .sqlvalue(@$_POST["xOFFICE"], true);
  };
  $pk .= ") and ";
  $pk .= "(EMAILID";
  if (@$_POST["xEMAILID"] == "") {
    $pk .= " IS NULL";
  }else{
  $pk .= " = " .sqlvalue(@$_POST["xEMAILID"], true);
  };
  $pk .= ") and ";
  $pk .= "(ADDRESS";
  if (@$_POST["xADDRESS"] == "") {
    $pk .= " IS NULL";
  }else{
  $pk .= " = " .sqlvalue(@$_POST["xADDRESS"], true);
  };
  $pk .= ") and ";
  $pk .= "(REMARKS";
  if (@$_POST["xREMARKS"] == "") {
    $pk .= " IS NULL";
  }else{
  $pk .= " = " .sqlvalue(@$_POST["xREMARKS"], true);
  };
  $pk .= ")";
  return $pk;
}
 
 
function ociquery($sql)
{
  global $conn;
 
  $res = ociparse($conn, $sql);
  ociexecute($res, OCI_DEFAULT) or die(ocierror());
  ocicommit($conn);
  return $res;
}
 
function ocifetchassoc($res)
{
  $ret_array = array();
  ocifetchinto($res, $ret_array, OCI_ASSOC);
  return $ret_array;
} ?>
 
Related Solutions
Keywords: php code modification for mysql from o…
 
Loading Advertisement...
 
[+][-]02/16/09 08:03 AM, ID: 23650962Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: PHP Scripting Language
Tags: php mysql
Sign Up Now!
Solution Provided By: Ray_Paseur
Participating Experts: 1
Solution Grade: A
 
[+][-]02/16/09 07:57 AM, ID: 23650907Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/16/09 08:09 AM, ID: 23651024Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02/16/09 08:17 AM, ID: 23651093Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02/16/09 08:30 AM, ID: 23651222Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02/16/09 08:31 AM, ID: 23651229Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02/16/09 08:34 AM, ID: 23651255Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/16/09 09:05 PM, ID: 23656484Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/17/09 06:19 AM, ID: 23659688Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625