Jump to content

yellowepi

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

yellowepi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. ty, I was wondering if i could create an array, but just could not figure out how to do it.
  2. I'm attempting to create code that will take the file names from a folder, insert the names into an image tag, and insert the images into a table. The problem with my code is that it uses the same image in every row. What would an easy way to be to fix this? <?php function printtd() { $dirname = "imagegallery"; $dh = opendir($dirname) or die("couldn't open directory"); while ($file = readdir($dh)) { if(preg_match("(jpg|bmp|jpeg|png|gif)", $file)) { echo "<img src='imagegallery/".$file."' height='15 %'/>"; } } closedir($dh); } ?> <?php echo "<table> \n"; for ($y=1;$y<=2;$y++) { echo "<tr> \n"; for ($x=1;$x<=6;$x++) { echo "<td> \n"; printtd(); echo"</td> \n"; } echo"</tr> \n"; } echo"</table> \n"; ?>
  3. After some more experimenting I solved part of the problem. I am now getting this error though. Warning: mysql_pconnect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /Applications/MAMP/htdocs/TacoHTMLEditTemp.php on line 15 Could not connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) How can you change the socket you are using. I copy and pasted the connection code from another file that works too. This is the socket that it should use:/Applications/MAMP/tmp/mysql/mysql.sock
  4. Sorry, its not an include question now, because I combined the files to try to figure out the problem. The include works fine.
  5. I am attempting to connect to a database using this script, but am getting a message that states no data base selected. Here's the code, I have tried calling it using a funtion, but so far no dice. Database name is test. <?php class dbControl { //set local variables var $dbhost = "localhost:8889"; var $dbuser = "root"; var $dbpass = "root"; var $dbname = "test"; //connect to database and select a database function dbConSel ($dbhost, $dbuser, $dbpass, $dbname) { //connect $db = mysql_pconnect($dbhost,$dbuser,$dbpass); if (!$db) { die('Could not connect: ' . mysql_error()); } mysql_select_db($dbname,$db) or die(mysql_error()); } //Select Table function selTable ($mysqlquery) { $result = mysql_query($mysqlquery) or die(mysql_error()); } } $dataconnect = new dbControl(); $dataconnect -> dbConSel ('localhost:8889, root, root, test'); $dataconnect -> selTable ("SELECT * FROM store_items WHERE cat_id=3"); echo $result; ?>
  6. I'm very new to programming, but I am attempting to at least understand MVC. I'm going to lay out a basic idea for what I understand. This is the frame(file structure) I would start everything in. Model- This will contain all of the data base(sql) retrieving functions. Controller- This will have objects that will be referenced to from my index.php in order to perform actions. Actions-Uses the Model folder to retrieve, send, update, delete data from the database; and reference to the correct 'template' in the View folder. View- This folder will have the css files, graphics files, and html files that the index.php will access to output the view according to the situation. I don't know if this is just a simplistic view of it or a wrong view, but this is what I have seemed to gleen from my reading this far. I would also have another folder for javascript and possibly also for larger php scripts with specific functions(shopping cart) etc.
  7. I had tried putting it in the html originally so i didn't think that was what it was, now I feel stupid. it worked--thanks
  8. I just checked it in safari and it only reders this way in camino/ff. It renders correctly in safari.
  9. I'm still fairly new to programming, but have monkeyed around with css a little. To me it would be easier to seperate the files out so they are specific to the browser and then use browser detection with if else function to reference to the correct css sheet. That way if you want to make a change you go to the browser you want to change and change it instead of working your way through all of the code that is intermixed. I think it would be a little laborious to work through using the css divs-i think you could potentially do it with if functions, but all individually and would take longer in my opinion.
  10. I have a purple outline or border, not sure which that I can not get rid of. I don't want any border or anything around the image. The image is a link with a rollover(javascript), I am not comfortable with javascript, but it does not seem to be the problem. It is only when I add the <a href> tag that it occurs. Heres my css, specifically .button. I posted all of them because I cant find the problem. .sidebar { position: absolute; width: 151px; height: 100%; top: 196px; bottom: 0px; left: 0px; background-color: #87c77d; z-index: 8; } .topbar { position: absolute; height: 200px; width: 100%; left: 0px; right: 0px; top: 0px; background-image: url('graphics/87c77dgradient.jpg'); repeat: x; z-index: 3; } .logotxt { position: absolute; left: 200px; top: 0px; height: 200px; width: 400px; z-index: 8; background-image: url('graphics/everydayedentext.png'); } .logocontainer { position: absolute; left: 15px; top: 15px; height: 150px; width: 195px; z-index: 4; background-image: url('graphics/everydayedenlogoshadow.png'); } .button { display: block; width: 150px; height: 40px; z-index: 9; color: white; } .topright { height: 50px; width: 50px; position: absolute; right: 0px; top: 0px; background-image: url('graphics/topright.png'); z-index: 9; } .topleft { height: 50px; width: 50px; position: absolute; left: 0px; top: 0px; background-image: url('graphics/topleft.png'); z-index: 9; } .bottomrightbanner { height: 50px; width: 50px; position: absolute; right: 0px; top: 150px; background-image: url('graphics/bottomright.png'); z-index: 9; } .leftcornerbody { height: 50px; width: 50px; position: absolute; left: 151px; top: 200px; background-image: url('graphics/leftcornerbody.png'); z-index: 9;} .bkgrnd { height: 500px; width: 500px; z-index: 2; top: 130px; left: 75px; position: absolute; background-image: url('graphics/TinyTulipPoplarLeaf.png'); } .bkgrnd2 { height: 500px; width: 500px; z-index: 1; top: 250px; right: 2%; position: absolute; background-image: url('graphics/TinyTulipPoplarLeaf4.png'); } .bkgrnd3 { height: 500px; width: 500px; z-index: 1; top: 100px; left: 400px; position: absolute; background-image: url('graphics/TinyTulipPoplarLeaf3.png'); } .textabout { position: absolute; width: 75%; min-width: 75px; height: 300px; top: 215px; left: 160px; color: blue; z-index: 8; } Heres the code for the <a href> <div class="sidebar"> <br /> <a href="index.php" onmouseover="document.button.src=buttonBottom.src" onmouseout="document.button.src=buttonTop.src"><img src="graphics/buttontophome.png" name="button"></a></div>
  11. I'm still very new at using php, and have heard of seperating all of this out. I know there are prebuilt templates like smarty etc, but how would you code this to make your own template? If it would take to long to explain-just say so and I will try to figure it out.
  12. I don't know if this is the best way to develop a form dynamically or not, but this is the way I did. I made an array and used the keys and values to fill in to make the form. [red] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN"> <html> <head> <title></title> </head> <body> <table><form> <?php $forminput = array( "Username" => "username", "First Name" => "fname", "Last Name" => "lname", ); foreach ($forminput as $field => $value) { echo "<tr><td>" .$field . ": </td> <td><input type='text' name='" .$value."'></td></tr>"; } ?> </form></table> </body> </html> Is this the best way for creation of a form, or are there better ways. I am new to programming and feel pretty good about this one, but since I am new I am sure there are better ways.
  13. Thankyou so much for the help. I think I have a much clearer understanding of these functions with the array now.
  14. Okay, yours is much clearer, but wouldn't work when I pasted it in. You left off a $ for the variable $field in the foreach statement. To reiterate to make sure I understand this. foreach($arrayvals as $record) This is placing the values of arrayvals into the variable $record, right? foreach ($record as $field => $value) { echo $field . ': ' . $value . '<br>'; This foreach statement is taking each of the records in the array and assigning them to field and value? name, age, and occupation are assigned to the first variable- $field and the data for each is assigned to the $value and printing them to the page. and for the function I used to start with foreach ($arrayvals as $a) { while (list($k, $v) = each ($a)) { echo "$k ... $v <br/>"; The arrayvals data is placed $a. list takes the first thing it sees in the array which would be the $key and places it in the first variable $k and then the second variable $v in the list function is the second thing it sees and places it in $v. and repeats do to the while statement for each $a. And prints. The [a>0] was me messing around to see what would happen. It was working too. I just forgot to erase it before I posted the code.
  15. I'm new to php and have been reading a lot, but I have been going through arrays and have a multidemensional array. When I want to print everything to the screen this is the code I used. To print the array values I used $a from $arrayvals, does php always take the first letter of the variable and use it as a variable? For the key I used $k and for the values I used $v, are these set in stone variables, or can you use any variable name you want for them? $arrayvals = array( array( "name" => "Taylor", "age" => "26", "occupation" => "Supernurse", ), array( "name" => "Rachel", "age" => "25", "occupation" => "Supernurse", ) ); echo $arrayvals[$a>0]['name']; foreach ($arrayvals as $a) { while (list($k, $v) = each ($a)) { echo "$k ... $v <br/>"; } } Any help would be very much appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.