Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Big Nubbins
Jun 1, 2004
Those were both good reads and if I were in charge of coding our sites myself, I'd probably lean toward Kohana. The other one seems to be a good choice if writing your own framework seems appealing.

I should've been more specific about our needs. Basically what I've come to find is that what we only really need is a robust database abstraction package. As I mentioned, I don't actually build websites, I pass that portion of developing a given site on to our content developers and then hold their hand through any PHP that may need done. In the case that something more complex needs done for a website, or any one-off function that requires heavy programming, I do that. I'd love to migrate to an MVC approach to building sites, but it wouldn't happen as our content guys are not quite that technical.

The system we have in place now is essentially a database abstraction layer, and I guess what I'm looking for is something that might be more sophisticated, a little more object oriented, and optimized a little better. None of us should hardly, if ever, need to write a query to fetch, manipulate, or store data. This is why our content developers don't need to be skilled at programming to produce dynamic pages (they come cheap if they're not programmers).

Adbot
ADBOT LOVES YOU

spiritual bypass
Feb 19, 2008

Grimey Drawer
So you're like for ORM, right?
Try Propel or Doctrine.

Have fun shoehorning graphic artists into the role of building a whole website!

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

greasy digits posted:

None of us should hardly, if ever, need to write a query to fetch, manipulate, or store data. This is why our content developers don't need to be skilled at programming to produce dynamic pages (they come cheap if they're not programmers).

Sounds like maybe you need a template engine?

epswing
Nov 4, 2003

Soiled Meat
I think php itself is a reasonably good templating engine.

MrMoo
Sep 14, 2000

epswing posted:

I think php itself is a reasonably good templating engine.

It can also be a reasonable framework but people love to aimlessly re-invent poo poo that some how ends up inferior to the original. Meh.

cLin
Apr 21, 2003
lat3nt.net
How do people deal with passing options thru the form considering each product might have a different option? I know you can use session/cookies to store the value but the way I have it now is that everytime someone adds an item to a cart, it'll send the data to a function which handles adding product to cart like this:

code:
$cart->handle_product($_POST['prod_id'], $_POST['quantity'], $_POST['price']);
My options are done by a dropdown and there could be multiple dropdowns per product so if I put them in an array, the output would be something like [option] => Array ( [0] => Clear [1] => Yes ) but the problem with that is I don't know what [0] and [1] since it might be different for every product. If I can label [0] and [1] I can just pass the option array into the function and have the function figure out how to deal with the data.

So I don't know how to go about handling options, any guidance would be appreciated. Something tells me it's something simple I missed but I can't seem to get past the whole.

MrMoo
Sep 14, 2000

cLin posted:

How do people deal with passing options thru the form considering each product might have a different option?

The first goal should be to have everything with a unique ID and see if your view can manage the collation of related IDs. If that is not sufficient you might want to consider something simply like a parent-ID reference, each option has a unique ID and you create a tree.

php:
<?
$cart->handle_product(array(
     'product-id'  => $_POST['prod_id'],
     'quantity'    => $_POST['quantity'],
     'price'       => $_POST['price'],
     'options'     => array(
          array(
               'option-id'   => $_POST['opt0_id'],
               ...
          ),
          array(
               'option-id'   => $_POST['opt1_id'],
               ...
          ))
...
));
?>
Try to avoid re-implementing a key-value database ontop of SQL like many shopping cart systems like to do.

cLin
Apr 21, 2003
lat3nt.net
Thanks! It's so much better when I can visual what I need to do. :)

crazypandaman
Jun 26, 2006
I am working on a website that will be serving a rather large number of downloads. I have been searching for a way to log the downloads of each of the files.

At the moment I am using a simple script to check the request to see if its valid, log the download and serve the file.

The below code snippet serves the file after the verification and logging functions.

php:
<?
$reqfile = "files/".$file;
$contenttype="audio/mpeg";

if($fn=fopen($reqfile, "rba")){
  header("Content-Type: ".$contenttype);
  header("Content-Length: ".filesize($reqfile));
  header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  header("Pragma: no-cache");
  header("Expires: Mon, 26 Jul 1997 06:00:00 GMT");
  header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0");
  fpassthru($fn);
  fclose($fn);
?>
To me this feels like a very inefficient way of serving the files. I load tested this earlier today and found it to be taxing on the server, the server load would shoot up when it hit around 40 concurrent downloads. This did not happen when downloading the file directly.

This is starting to drive me crazy. What would be a more efficient way of logging and serving the file?

MrMoo
Sep 14, 2000

crazypandaman posted:

To me this feels like a very inefficient way of serving the files.

Check out x-send-file, on new versions of Apache or Lighttpd.

http://john.guen.in/past/2007/4/17/send_files_faster_with_xsendfile/

every
Apr 24, 2008

How can I pass my php array to a javascript function?

Right now, I'm just passing $data as an argument and alerting it on the other side...and I'm just getting a 'native code' alert.

Do I have to pass it through as a string, or is there a better way? Thank you.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

growing posted:

How can I pass my php array to a javascript function?

Right now, I'm just passing $data as an argument and alerting it on the other side...and I'm just getting a 'native code' alert.

Do I have to pass it through as a string, or is there a better way? Thank you.

Pass it as a json formatted string and then parse the JSON in Javascript.

gwar3k1
Jan 10, 2005

Someday soon
edit: nevermind.

Q: Do you need multiple instances of a connection variable when using nested SQL queries and mysqli
A: Yes

gwar3k1 fucked around with this message at 22:01 on Mar 3, 2010

KarmaticStylee
Apr 21, 2007

Aaaaaughibbrgubugbugrguburgle!

MrMoo posted:

It can also be a reasonable framework but people love to aimlessly re-invent poo poo that some how ends up inferior to the original. Meh.

One of the main reasons I like frameworks is good, consistent application organization

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

gwar3k1 posted:

edit: nevermind.

Q: Do you need multiple instances of a connection variable when using nested SQL queries and mysqli
A: Yes

That doesn't sound right. You can, at least, have more than one result object at a time; there is no need, so far as I know, to have more than one connection resource at a time, assuming you only want to connect to one host.

code:
$link = mysqli_connect( connection variables );
$my_toplevel_query = mysqli_query($link,'do something');
while ( $row = mysqli_fetch_assoc($my_toplevel_query) ) { // for example
    $my_nested_query = mysqli_query($link,'do something else');
}

gwar3k1
Jan 10, 2005

Someday soon

Hammerite posted:

That doesn't sound right. You can, at least, have more than one result object at a time; there is no need, so far as I know, to have more than one connection resource at a time, assuming you only want to connect to one host.

code:
$link = mysqli_connect( connection variables );
$my_toplevel_query = mysqli_query($link,'do something');
while ( $row = mysqli_fetch_assoc($my_toplevel_query) ) { // for example
    $my_nested_query = mysqli_query($link,'do something else');
}

Thanks, I'll give it another try. I had a few other issues to debug so I just assumed that that was one of the causes.

MrMartyn
Mar 6, 2007

I'm doing some coursework for my web module at university and I've just got a quick, simple question. I'm trying to enter values from a form into 2 tables (login & customer) connecting the 2 based on the UserId as the foreign key but I can't seem to pass the UserId from the SELECT statement into a variable so it can be used in the following INSERT query, can someone point out where I've gone wrong?

code:
<?php
		
					//connect to database
					$location = "ftemysql";
					$username = "k0607077";
					$password = "56660";
					$database = "k0607077";
					   $conn=@mysql_connect("$location","$username","$password");
					if (!$conn) die ("Error: Could not connect to database server.");
					@mysql_select_db($database,$conn) or die ("Error: Could not open database.");
					
					$querycreatelogin = mysql_query("CREATE TABLE Login
					(
						UserId INT(3) NOT NULL AUTO_INCREMENT,
						Username Varchar(25),
						Password Varchar(100),
						PRIMARY KEY (UserId)
					)");
					
					$querylogin = mysql_query("INSERT INTO Login VALUES ('','$regusername','$regpassword')");
										
					$queryselectuser = mysql_query("SELECT UserId FROM Login WHERE Username = '$regusername'");
								
					$result = mysql_query($queryselectuser);
					$userid = mysql_fetch_assoc($result);
				
					$createcustomer = mysql_query("CREATE TABLE Customer
					(
						CustomerId INT(8) NOT NULL AUTO_INCREMENT,
						FirstName Varchar(30),
						Surname Varchar(30),
						Address1 Varchar(30),
						Address2 Varchar(30),
						Address3 Varchar(30),
						County Varchar(30),
						Postcode Varchar(9),
						Sex Varchar(3),
						UserId Varchar(8),
						PRIMARY KEY (CustomerId),
						FOREIGN KEY (UserId) RFERENCES Login(UserId)
					)");
					
					$querycustomer = mysql_query("INSERT INTO Customer VALUES ('','$firstname','$surname','$addressline1'
,'$addressline2','$addressline3'
,'$county','$postcode','$sex','$userid')");
					
			die ("Your registration has been successful!");	
		
?>

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
After you have called mysql_fetch_assoc, $userid is an associative array, not a string or an integer. It has a single key, 'UserId', and the value associated to that key is the User ID you are trying to use in your subsequent query.

To solve this problem you could either

1) wrap the call to mysql_fetch_assoc with a call to extract()
2) change $userid in the final query to $userid['UserId']

Also,

1) you are aware that you have posted your database user's credentials?
2) you might find it handy to look up "last insert id"

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Hammerite posted:

1) wrap the call to mysql_fetch_assoc with a call to extract()
By this I mean change

$userid = mysql_fetch_assoc($result);

to

extract(mysql_fetch_assoc($result));

If you do this then $UserId will contain the value you require (not $userid, which is capitalised differently)

mik
Oct 16, 2003
oh
This may be a question without an answer, or too vague to answer, but we'll see...

This is basically a code optimization problem, it's too slow.



I have a script that I run that does some rather lengthy logic. The script combines two dynamic variables (say A & B) with some data from a big database that I have of gathered variables basically arranged as such:

date | time | station | reading

There's 400 stations and 400 readings per day, and 34 days of data so I have roughly 5 million records in this particular mySQL database.

With the data I want to be able to retrieve and manipulate it in three different ways:

1) Single Date output, given single values of A & B

2) Sum of daily output for all 30 days, given values of A & B

3) Same as #2, but over all combinations of A & B (each variable can be one of 8 values, so this is 64 combinations or running #2 64 times in a row to print out a 8x8 table).

Originally, I was pulling the data out of the giant database and putting into a temporary table, then reading that table every time the function #2 runs. This yielded an execution time of about 6 seconds per #2, or 6x64=380 seconds in total. This is currently too slow.

So I thought maybe reading from the temp table was what was causing the script to be slow and instead i just pulled the data from the big database once then loaded it into a php array and carried the array through all 64 iterations.

With this method, running #2 takes roughly 2.5 seconds which is acceptable. The problem I am having is when doing #2 64 times in a row for #3, my script it total takes much longer than 2.5x64. In fact, while the first iteration takes about 2.5 seconds, each successive iteration takes .2 seconds longer, by the time I've completed the 64th iteration, it's taking over 9 seconds each time. And finally the total execution time is even longer than before, about 450 seconds.

Why is performance degrading like this? Am I 'leaking' somewhere?

I've regained some time by unset() and re-populating the array each time #2 runs (so pulling out of the giant database and making the big array 64 times), but each successive run of #2 still takes longer and longer. I realise this might be some inherent problem with this type of thing (diminishing returns or something), but is there anything I can do to prevent this?

Sorry if this is a disjointed post, I kinda hack my way through PHP (all personal stuff) and am completely lost on this one. The code is too long to submit, but I can mock up some pseudocode if it will help.

mik fucked around with this message at 06:43 on Mar 7, 2010

gwar3k1
Jan 10, 2005

Someday soon
Edit, stupid question.

MrMartyn
Mar 6, 2007

Hammerite posted:

By this I mean change

$userid = mysql_fetch_assoc($result);

to

extract(mysql_fetch_assoc($result));

If you do this then $UserId will contain the value you require (not $userid, which is capitalised differently)

Really struggling with this, made the changes that you suggested and it prints out '1' as the ArtistId in the echo statement no matter what artist is entered into the textbox and when it inserts the data a 0 is entered into the table.

Below is the code (to a different page) that I made amendments to based on your suggestion, can anyone see what I'm doing wrong still?

code:
$querycreatesong = mysql_query("CREATE TABLE Song
					(
						SongId INT(3) NOT NULL AUTO_INCREMENT,
						Title Varchar(50),
						Album Varchar(50),
						Price Double,
						Genre Varchar(30),
						ArtistId Int(3),
						PRIMARY KEY (SongId),
						FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)
					)");
					
					$queryselectartistid = mysql_query("SELECT ArtistId FROM Artist WHERE Name ='$artist'");    
					
					$artistid = extract(mysql_fetch_assoc($queryselectartistid));

					echo $artistid;

					$queryaddsong = mysql_query("INSERT INTO Song VALUES ('','$title','$album','$price','$genre','$artistid'['ArtistId'])");    

					die ("Your song was successfully added!");

Jackie
Jun 18, 2004
<3

MrMartyn posted:

Really struggling with this, made the changes that you suggested and it prints out '1' as the ArtistId in the echo statement no matter what artist is entered into the textbox and when it inserts the data a 0 is entered into the table.

Below is the code (to a different page) that I made amendments to based on your suggestion, can anyone see what I'm doing wrong still?

code:
$querycreatesong = mysql_query("CREATE TABLE Song
					(
						SongId INT(3) NOT NULL AUTO_INCREMENT,
						Title Varchar(50),
						Album Varchar(50),
						Price Double,
						Genre Varchar(30),
						ArtistId Int(3),
						PRIMARY KEY (SongId),
						FOREIGN KEY (ArtistId) REFERENCES Artist(ArtistId)
					)");
					
					$queryselectartistid = mysql_query("SELECT ArtistId FROM Artist WHERE Name ='$artist'");    
					
					$artistid = extract(mysql_fetch_assoc($queryselectartistid));

					echo $artistid;

					$queryaddsong = mysql_query("INSERT INTO Song VALUES ('','$title','$album','$price','$genre','$artistid'['ArtistId'])");    

					die ("Your song was successfully added!");

Here is the documentation for extract: http://php.net/manual/en/function.extract.php

If one of the keys in your array is 'ArtistId' (and it is, based on your query) then after you call extract(), you will have a variable $ArtistId which holds the value you are looking for.

So, change
code:
$artistid = extract(mysql_fetch_assoc($queryselectartistid));
to just
code:
extract(mysql_fetch_assoc($queryselectartistid));
and any place you want the artist's ID use the variable $ArtistId

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
From the documentation page linked by Jackie:

PHP documentation posted:

Return Values

Returns the number of variables successfully imported into the symbol table.

The code you are using always stores integer 1 in the variable $artistid because the argument you are passing to extract() is an associative array with one key, 'ArtistID'.

If you run this code:

code:
$A = array();
$B = array('dessert' => 'icecream');
$C = array('cat' => 'mittens', 'dog' => 'fido', 'budgie' => 'brett');

$X = extract($A);
$Y = extract($B);
$Z = extract($C);

echo $dog;
then you will see as output 'fido'. Following the first six lines, the variables $X, $Y and $Z contain the values integer 0, integer 1 and integer 3, respectively. Furthermore there are 4 new variables: $dessert, $cat, $dog and $budgie, which have the values string 'icecream', string 'mittens', string 'fido' and string 'brett', respectively.

In the case of your code, you do not care about the value returned by extract() because you know that whatever happens it should return integer 1. You care about the new variable it has created, $ArtistId, which is independent of its return value.

Begby
Apr 7, 2005

Light saber? Check. Black boots? Check. Codpiece? Check. He's more machine than kid now.

mik posted:

stuff

Well, I can't give you all that much help without seeing some code, but here are some general things you can look at

- One possible bottleneck is building up and tearing down SQL connections. Everytime you create a new query and connect, it takes time and a lot of resources. Really bad bad things are to create a query, then loop over the results and do another query for each result, then for each of those results do another query etc. I have seen this done a lot in code I have fixed and it tends to get bad fast. Are you doing anything like that?

- Are you using PDO or some other technology? Are you creating a new connection for every query or reusing a connection? You might want to open up a mysql console and look at the connections as your app runs and see what happens. If a million connections open up you have a problem.

- Are your tables properly indexed? Have you done ran 'explain' on your queries? 5 million records sounds like a lot, but on a properly setup server its really not a large number of records for MySql to handle

- Have you tried getting your complete results in a single query instead of doing all of this in PHP? I am 99% sure there would be some way to get the results for #2 and #3 using a single query and no temp table. You should start out using a MySql client app and create the queries, then when you get the results setup, just use PHP to run the queries.

- Post your pseudo code, this will probably be the biggest help

- Post some sample data, some sample values for A & B, along with what you want your results to look like for #1, #2, and the calculations that would happen to get those results.

Very simplified example
code:
Data:
Name      Birthdate
Fred      1/23/1976
George    5/01/1987
Earl      2/21/2001
I want to find the number of users that are 21 or older, so for the above data, the result should be "2". You would get to this by calculating the age of each person by subtracting their birthdate from todays date and rounding down to the nearest whole year, then count how many of those people are 21 or older.

- Post your SQL queries you are using.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

I'm very new at web development, so please bear with me.

I have a database of employees. We can call it EMPLOYEES, I guess it doesn't matter. My first page, let's call it main.php, takes a first name and a last name for input, by way of a regular HTML <form>. When submitted, employee_search.php is called. This page makes an SQL query and retrieves the employees from the database who match the criteria entered.

So if you entered "John" for first name and a blank last name, you would get:

John Anderson
John Jones
John Smith
John Williams
...

etc

code:
 echo "<CENTER><TABLE><TR><B>Search Results</B></TR>";
  while($row = mysqli_fetch_assoc($result))
  {
   extract($row);
   echo "<TR><TD><A HREF='edit_employee.php'>$FirstName $LastName</URL></TD>";
   echo "<TD><IMG SRC='icons/spacer50.gif'></TD><TD>$Department</TD></TR>";
  }
 echo "</TABLE></CENTER>";
Right now, as you can see I just have it dumping to a table of HTML. What I would like to do, is make each of those into a link where you could click on, and then it will bring up employee_detail.php, showing you the employees information like height, weight, etc.

Here's my question - what way should I do it? I would like to avoid linking to 'employee_detail?ID=2352' (the ID would come from the SQL database)

Would it be over-complicating things to make another form out of the table, with each returned person being a possible selection in that form? I could then have the form call employee_detail.php and just retrieve that field from the submitted form. Can I even do that?

Or is there a better way to do it that I'm not thinking of?

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Bob Morales posted:

Here's my question - what way should I do it? I would like to avoid linking to 'employee_detail?ID=2352' (the ID would come from the SQL database)

Would it be over-complicating things to make another form out of the table, with each returned person being a possible selection in that form? I could then have the form call employee_detail.php and just retrieve that field from the submitted form. Can I even do that?

Or is there a better way to do it that I'm not thinking of?

Do you mean a select element with multiple='true' set? In that case you add a [] to the name of the element in HTML: name='herdOfEmployes[]' and then you can treat the argument as an array of strings in PHP: $_REQUEST['herdOfEmployes'][0]

Otherwise I'm not sure what you mean :allears:

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

Munkeymon posted:

Do you mean a select element with multiple='true' set? In that case you add a [] to the name of the element in HTML: name='herdOfEmployes[]' and then you can treat the argument as an array of strings in PHP: $_REQUEST['herdOfEmployes'][0]

Otherwise I'm not sure what you mean :allears:

If you had a list of search results like mine (employee list), how would you make the links so that you could click on each one and launch an 'edit employee' page?

SiCk
Jul 4, 2003

My name's SiCk, and I'm the Biggest Idiot Ever!
Basically, he wants to hit e.g. edit_employee.php, and pass an argument to show the data for that user, but without directly linking to it with a $_GET / edit_employee.php?userid=xxx

I'm not 100% how you would do this.. Maybe some .htaccess tomfoolery? - You could maybe pass it as edit_employee.php?userid=xxx and hide it with a rewrite of some sort..

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Bob Morales posted:

Here's my question - what way should I do it? I would like to avoid linking to 'employee_detail?ID=2352' (the ID would come from the SQL database)

Why? That's how you should do it. If you don't want employee ids to be known, do something to encrypt/decrypt it.

Also, your HTML needs some work. Use lowercase tags. No <center> tags, use CSS. You are also missing some column definitions. Take a look at this html references.

fletcher fucked around with this message at 00:31 on Mar 9, 2010

SiCk
Jul 4, 2003

My name's SiCk, and I'm the Biggest Idiot Ever!

fletcher posted:

Why? That's how you should do it. Also, your HTML needs some work. Use lowercase tags. No <center> tags, use CSS. You are also missing some column definitions. Take a look at this html references.

That's kind of what i was thinking.. I've never really seen ( well.. noticed ) it done any other way.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

fletcher posted:

Why? That's how you should do it. If you don't want employee ids to be known, do something to encrypt/decrypt it.

Also, your HTML needs some work. Use lowercase tags. No <center> tags, use CSS. You are also missing some column definitions. Take a look at this html references.

Alright, if that's the way to do it, that's the way I will do it.

I know about the CSS stuff but I wasn't worried about that right now, I'll get up to speed on going beyond deprecated HTML next. Like I said, it's been a long time.


I guess what I was thinking was like this:

code:
<form action='edit_employee.php' method='post'>
  // search results follow
  while ($row = mysqli_fetch_assoc($result))
  {
   extract($row);
  
   <input type='whatever' label='$firstname $lastname' employee_id='$ID'>
  }
</form>

Bob Morales fucked around with this message at 00:41 on Mar 9, 2010

Little Brittle
Nov 1, 2004

Come visit me dawg
I have an image resizing script that runs fine from my public html directory, but when I move it into my private directory and try to run it as a cron job, it gives me file permission errors. It seems it can read filesizes, but it cannot open or copy files. I've tried to chmod all the appropriate directories 777 to test it out, but that doesn't work. Do I need to run the cron script as a different user? How do I do that? Here is how I'm running it out of Plesk's crontab:

code:
php /var/www/vhosts/mywebsite.com/private/cronjobs/test.php

Little Brittle fucked around with this message at 00:57 on Mar 9, 2010

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Bob Morales posted:

Alright, if that's the way to do it, that's the way I will do it.

I know about the CSS stuff but I wasn't worried about that right now, I'll get up to speed on going beyond deprecated HTML next. Like I said, it's been a long time.


I guess what I was thinking was like this:

code:
<form action='edit_employee.php' method='post'>
  // search results follow
  while ($row = mysqli_fetch_assoc($result))
  {
   extract($row);
  
   <input type='whatever' label='$firstname $lastname' employee_id='$ID'>
  }
</form>

Don't get me wrong, it could work. It's just not what the POST method was really intended for. Read about what the difference between a GET and a POST is for more information. A general rule of thumb is to use a POST when you are going to be modifying some data. If you just want to retrieve some data, use a GET.

Like this message I'm typing for example. I'm going to POST it to the forums, and it will redirect me to a link that will GET the thread, with the thread id # in the URL.

Bob Morales
Aug 18, 2006


Just wear the fucking mask, Bob

I don't care how many people I probably infected with COVID-19 while refusing to wear a mask, my comfort is far more important than the health and safety of everyone around me!

fletcher posted:

Don't get me wrong, it could work. It's just not what the POST method was really intended for. Read about what the difference between a GET and a POST is for more information. A general rule of thumb is to use a POST when you are going to be modifying some data. If you just want to retrieve some data, use a GET.

Like this message I'm typing for example. I'm going to POST it to the forums, and it will redirect me to a link that will GET the thread, with the thread id # in the URL.

That's the explanation I wanted. Thanks.

spiritual bypass
Feb 19, 2008

Grimey Drawer
Dumb question; nevermind.

spiritual bypass fucked around with this message at 05:31 on Mar 9, 2010

Juanito
Jan 20, 2004

I wasn't paying attention
to what you just said.

Can you repeat yourself
in a more interesting way?
Hell Gem
I've got this site with a crappy guestbook script. For every 10 posts, it creates a new page. The problem is that at the bottom of the guestbooks, it has all the other pages numbered. In the case of the sample guestbook, there are like 500 pages, and all of the numbers cause the page to stretch since they don't wrap. How can I make this so that <br> is inserted every so often?

Thanks

code:
echo "<tr><td><font size=3>Page: &nbsp;";
					for($i=0; $i< $total_page ;$i++)
						echo "<a href='guestbook.php?id=$uid&start=".($i*$page_size)."'>".($i+1)."</a>&nbsp;";

Peanut and the Gang
Aug 24, 2009

by exmarx
Switch the &nbsp; to a regular space. Then it will auto-wordwrap.

So it will be: ...($i+1)."</a> "

Peanut and the Gang fucked around with this message at 04:25 on Mar 10, 2010

Juanito
Jan 20, 2004

I wasn't paying attention
to what you just said.

Can you repeat yourself
in a more interesting way?
Hell Gem
Ha, that did it. Thanks so much!

Adbot
ADBOT LOVES YOU

spiritual bypass
Feb 19, 2008

Grimey Drawer

barbarianbob posted:

Switch the &nbsp; to a regular space. Then it will auto-wordwrap.

So it will be: ...($i+1)."</a> "

That's called a non-breaking space, by the way. It's a space that doesn't cause line breaks.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply