Hi. Im new to PHP and know very little, and all I want to know if it is possible to do the following (an example). I have a list of computer screens names only. I want to place the names of the screens in the exact same places ( 4 places in total ) on one page each. Is this possible?
Lets see.. possible if you store it on a database then query the server yea it is Although the explanation is still vague =/ elaborate more please
Eh, I know very little about databases. Ill try to elaborate. Im creating a website where I need to have the same phrase in a page multiple times. I have a list of theses phrases.
Well, you can always go with arrays and do a foreach and echo them. example: $myphrase = array("I'm so cool", "Dunkin Botex", "Yay, pizza"); foreach ($myphrase as $k => $v) { echo $v."<br />"; } PHP: That should work
If you know how to get it from the db (there are different ways, depending on how you are set up), put it in a variable, like $phrase then, in your html, just put <?php echo $phrase?> Code (markup): wherever you want it to appear. This is assuming you want the same exact phrase in different places on the page.
Thanks! Can you show me what I would put in the actual page? I need an example, all I know how to do in PHP is includes
That depends on how much you know in using php. if you do the array all you have to do is echo $myphrase[0]; echo $myphrase[1]; (p.s you can make it random too)
I want to create multiple pages each with different content(names are the only difference ), so would this work fine for me?
You know you should just post an example of a site that matches what you want because I'm having a little trouble defining what you want exactly =/
Ok. The computer screens was an example. The website is www.myhighschool.co.uk. I want to auto fill the school names.
http://www.myhighschool.co.uk/high-school/abraham-moss-high-school.php On that page the word abraham moss high school is repeated multiple times. Thats what I want to put in, the word abraham moss high school.
You will want to make a query to get the whole record from the db - School name, address, comments, etc. and store the record in an array (or object) the example link you gave would have already done something like this, so if you have access to it, look at the code. if an array, your data would be like : $record[0] //school id $record[1] //school name $record[2] //comments each element would be a different field for that record in the db. so then , all you would need to do would be to echo $record[1] wherever you want the school name to appear in the html.
So If i only wanted to include the name, would i do it like this? $record[0] //Abraham Moss High School $record[1] //Burnage High School $record[2] //Cedar Mount High School And then echo $record[0] on the Abraham Moss High School page. And then echo $record[1] on the Burnage high school page? or did I just over complicate it
I think you are over complicating it, it's fairly easy, read a bit more, if you still don't understand it take a break and when you are ready get back on it
The html is just the template; each html page would contain $record[0] //school id $record[1] //school name $record[2] //comments, etc. if you think of the data as a spreadsheet, it would be more like: $record[0] //school id $record[1] //school name $record[2] //comments 1 Abraham Lincoln HS good school 2 Burnage HS old school Code (markup): everything in the row is a part of $record (which will only hold one row at a time) that's why you have to reference each part (db field) in the square brackets[]