4 Replies - 559 Views - Last Post: 24 April 2013 - 11:26 PM Rate Topic: -----

#1 beneran  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-April 13

make multiple page to one page load

Posted 24 April 2013 - 09:57 PM

how to make multiple page to be one page with php code
the page are showing data from database using mysql so th page become many
in this i just want to load all data into one page only not multiple page.

example :tes.php?v=1 to tes.php?v=33


in that many page use this to show as multiple page

$iprovi=$_GET['v'];


if i erase that code so many errors show from other script that depend on it because the script calling that code

and if i erase it errors show like :
Notice: Undefined variable: iprovi in C:\AppServ\www\tes.php on line 94

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\tes.php on line 95

Warning: Division by zero in C:\AppServ\www\tes.php on line 98

Notice: Undefined variable: iprovi in C:\AppServ\www\tes.php on line 102

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\tes.php on line 104

Notice: Undefined variable: iprovi in C:\AppServ\www\tes.php on line 146

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\tes.php on line 147

Warning: Division by zero in C:\AppServ\www\tes.php on line 150


please help me solve this problem

Is This A Good Question/Topic? 0
  • +

Replies To: make multiple page to one page load

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: make multiple page to one page load

Posted 24 April 2013 - 10:20 PM

OK, so I gather you have a PHP page that shows an item from MySQL based on an ID from the query string. And instead of showing the single item based on that ID, you want to show a list of all the items?

The solution to this is obviously not to just delete the ID variable. That does nothing but break the code that fetches the single item based on that ID. You'll actually have to rewrite some of that code so that, instead of loading one item by ID, it loads a bunch of items. This will involve rewriting the SQL query, and adding looping constructs to the code that interprets the database result.
Was This Post Helpful? 0
  • +
  • -

#3 beneran  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-April 13

Re: make multiple page to one page load

Posted 24 April 2013 - 10:38 PM

i did try deleting some code that depend on that script :

$iprovi=$_GET['v'];


some are work others not and thats killing me to solve the problem especially when errors like

few line code that work if i delete
Notice: Undefined variable: iprovi in C:\AppServ\www\tes.php on line 94

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\tes.php on line 95

Warning: Division by zero in C:\AppServ\www\tes.php on line 98

Notice: Undefined variable: iprovi in C:\AppServ\www\tes.php on line 102


Attached Image

changes
Attached Image

can you help me so i not write one by one code just to throw away that code. and yes based on that ID, i want to show a list of all the items
Was This Post Helpful? 0
  • +
  • -

#4 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3730
  • View blog
  • Posts: 6,017
  • Joined: 08-June 10

Re: make multiple page to one page load

Posted 24 April 2013 - 10:51 PM

All that these errors (or warnings and notices, actually) are telling you is that because you deleted the "iprovi" variable, it's missing and the code that relies on it isn't working. - You can not simply go into the code and start deleting things. That won't solve anything.

I'm not sure what you are expecting us to do here. It's clear that the code you are working on was not written for the purpose you are trying to put it to. You need to write another code for that, or do some well placed adjustments. Taking existing code and trying to get it to work by deleting random things you don't really understand how work is doomed to fail, and there isn't much I can tell you that will change that.

The first thing you need to do when editing old code for a new purpose is to get to know the old code; understand how it works. Can you do that? Can you read through the code and explain what each line is doing?
Was This Post Helpful? 0
  • +
  • -

#5 beneran  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 24-April 13

Re: make multiple page to one page load

Posted 24 April 2013 - 11:26 PM

i understand what you mention. the old code is to show all data from mysql database
why i deleting it is to load into one page instead so i can export it to excell file so when someone need it i can just export it and make few changes based on person request for other purpose.

i do this just on 2 or 3 page on website. i just put the export to excel button on when someone press it this code work the rest. this code is based on that code loading data from mysql database. the code working to make that many page into one page only containing all data.

i know deleting some code not solve the problem but it does save many time working new one. thank you atli for you fast and good response.

do have exsample how export it to excel from existing code based code i have. i have looked through google but not find what i search for

this are some code from the code i work right now
<?php

    error_reporting(E_ALL);

    require "koneksi.php";
	
	//$iprovi=$_GET['v'];
   
    $qry_3 = mysql_query("SELECT nama_propinsi FROM peta_propinsi");
    $rqry_3 = mysql_fetch_array($qry_3);
    $propinsi = $rqry_3['nama_propinsi'];

?>


<?php

    error_reporting(E_ALL);
    require "koneksi.php";
	
	$q2=mysql_query("SELECT SUM(anggaran) AS vkangg, SUM(komp_fis + non_fis) AS vkrangg, AVG(persen_fisik) AS senfisvk FROM form_isian WHERE publish='Y' GROUP BY id_prov");
$r2=mysql_fetch_array($q2, MYSQL_ASSOC);
$vkdana=number_format($r2['vkangg'],0,',','.');
$zranggvk=number_format($r2['vkrangg'],0,',','.');
$vksen_dana=number_format((($r2['vkrangg']/$r2['vkangg']) * 100),2,',','.');
$avgrfisvk=number_format($r2['senfisvk'],2,',', '.');
echo "<tr style='font-weight:bold;'><td align='right'></td><td colspan='2'>Provinsi $propinsi</td><td align='right'>$vkdana</td><td colspan='2'></td><td align='right'>$zranggvk</td><td align='center'>$vksen_dana</td><td colspan='2'></td><td align='right'>$avgrfisvk</td><td></td></tr>";

$q02=mysql_query("SELECT id_sub_sektor FROM form_isian WHERE id_prov=$iprovi AND publish='Y' GROUP BY id_sub_sektor ORDER BY id_sub_sektor ASC");
$n02=1;
while ($r02=mysql_fetch_array($q02)){
$issk=$r02['id_sub_sektor'];

$q05=mysql_query("SELECT nama_sub_sektor FROM dukungan WHERE id_sub_sektor=$issk");
$r05=mysql_fetch_assoc($q05);
$nssk=$r05['nama_sub_sektor'];

$q07=mysql_query("SELECT SUM(anggaran) AS svkangg, SUM(komp_fis + non_fis) AS svkrangg, AVG(persen_fisik) AS fispsnvk FROM form_isian WHERE id_prov=$iprovi AND id_akses='3' AND id_sub_sektor=$issk AND publish='Y'");
$r07=mysql_fetch_array($q07);
$svkdana=number_format($r07['svkangg'],0,',','.');
$svkrdana=number_format($r07['svkrangg'],0,',','.');
$sen_svkr=number_format((($r07['svkrangg']/$r07['svkangg']) * 100),2,',','.');
$fis_psnvk=number_format($r07['fispsnvk'],2,',', '.');
echo "<tr style='font-weight:bold;'><td></td><td align='right'></td><td>$nssk</td><td align='right'>$svkdana</td><td colspan='2'></td><td align='right'>$svkrdana</td><td align='center'>$sen_svkr</td><td colspan='2'></td><td align='right'>$fis_psnvk</td><td></td></tr>";



sometimes the code show error like this
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\tes.php on line 147

Warning: Division by zero in C:\AppServ\www\tes.php on line 150 <<<<===


but some are not. the division by zero is working on early line of the code but to more line it show error if delete the "$iprovi" and that "mysql_fetch_array()" error and "mysql_fetch_assoc()" error to. i search solve from google and try not fixing the error it keep showing error.

can someone give a solution ???
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1