-
Posts
364 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Love2c0de
-
If you're putting it in a table, put each bit of data in it's own <td> tag, for example test this: <?php $test_ar = array('a','b','c','d','e'); $output = "<table>"; for($i=1;$i<=10;$i++){ $output .= "<tr><td>"; $output .= $i; $output .= "</td>"; foreach($test_ar as $count){ $output .= "<td> $count-</td>"; } $output .= "</tr>"; } $output .= "</table>"; ?> <html> <head> <style type="text/css"> table,tr,td{border: 1px solid black;} </style> </head> <body> <?php print($output); ?> </body> </html> Regards, L2c.
-
Hi, I have a select query where I query 2 tables and retrieve all the data. When I send the results through a while loop, printing the rows, I am getting the information I need but it seems to be an indexed and associative array all in one. Here is sample output from 1 row. Array ( [0] => 1 [id] => 1 [1] => dsdaddda [username] => dsdaddda [2] => $2a$08$xi0Aem5dgJkyZbFbXVb6/.CY9AxFt0jJ.5W5ohamRyEgAgFiVHh22 [password] => $2a$08$xi0Aem5dgJkyZbFbXVb6/.CY9AxFt0jJ.5W5ohamRyEgAgFiVHh22 [3] => [email protected] [email] => [email protected] [4] => 2013-01-05 20:52:53 [join_date] => 2013-01-05 20:52:53 [5] => 1 [6] => Counter-Strike 1.6 [game_id] => Counter-Strike 1.6 [7] => singleplayer.dem [file_name] => singleplayer.dem [8] => DFDS [demo_name] => DFDS [9] => bvjjbkjb c cgfc gvjhhj [demo_desc] => bvjjbkjb c cgfc gvjhhj [10] => Ricciz0rz [uploaded_by] => Ricciz0rz [11] => 1359608484 [upload_date] => 1359608484 ) Why am I getting the results twice? Is this normal? Regards, L2c.
-
I don't understand the effect you want. Do you want your image in the middle, with the text still next to it? Regards, L2c.
-
Can you show your markup please? I might be able to get you started. Regards, L2c.
-
Ah I see. It's working in the source but not in the url bar where I want it to. How would I go about doing that? Regards, L2c.
-
Thanks kicken. It's not working for me though, when I hover over the link and even when I click it, it's showing as g=Battlefield 3 still. Regards, L2c
-
In the example on php.net it shows the function being used with commas when concatenating and not periods which I thought was strange as I'd never seen that. http://php.net/manual/en/function.rawurlencode.php Regards, L2c.
-
Hi guys and girls, I'm passing some data through the url such as the name of a game to be used later in a query. Not highly sensitive but I wanted to rawurlencode it. Can't seem to ever be able to use functions within urls. Here is what I've got: <?php if(isset($_SESSION['username'])) { /* echo "<div id='home_link_div'>"; echo "<a href='?page=home'>ALL</a>"; */ echo "<a href='?page=home&g=",rawurlencode("Battlefield 3"),"'>BF3</a>"; /* echo "<a href='?page=home&g=Counter-Strike 1.6'>CS 1.6</a>"; echo "<a href='?page=home&g=Counter-Strike: Source'>CS:S</a>"; echo "<a href='?page=home&g=Deus Ex'>DX</a>"; echo "<a href='?page=home&g=Left 4 Dead 2'>L4D2</a>"; echo "<a href='?page=home&g=Call Of Duty: Modern Warfare 4'>MW3</a>"; echo "</div>"; */ } ?> Im just trying to get the first one to work then I can apply that to the others. I have commented the others out and spaced them down for readability. Thank you for any help you can give me. Kind regards, L2c.
-
Try: echo "selected='selected'"; and if you want to use double quotes for the attributes, just escape the two nested double quotes with a backslash. Regards, L2c.
- 4 replies
-
- attributes construct error
- couldnt find end of start
- (and 1 more)
-
Wow I was never aware we could run php from the command line. I was at work when I replied to that, usually I would just test something before asking a question etc. So eunning PHP from the command line means we don't need a local server for example to run PHP scripts? I'm going to give the php.net a thorough read regarding CLI when I get back. I might do a bit of PHP in my break now, they already got n++ installed Kind regards, L2c.
-
Wouldn't PHP interpret {name} as a constant? Regards, L2c.
-
If you are going to be displaying certain things depending on what a user chooses, I would create your form with PHP, using if statements to decide what to display and what not to display. Regards, L2c.
-
No problem, glad you solved you issue! Regards, L2c.
-
Hi dude, Consider this code, this is something I wrote not so long ago for my own site: <?php ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>HTML Template</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <script type="text/javascript" src="jquery-1.8.3.js"></script> <style type="text/css"> #content_wrapper { width: 1000px; margin: 10px auto; } #left_container { width: 200px; height: 400px; float: left; text-align: center; font-size: 12px; background: #252527 url('../images/background_img.jpg'); border: 1px solid #fff; -moz-border-radius-bottomleft: 10px; border-bottom-left-radius: 10px; -moz-border-radius-topleft: 10px; border-top-left-radius: 10px; -moz-border-radius-bottomright: 10px; border-bottom-right-radius: 10px; -moz-border-radius-topright: 10px; border-top-right-radius: 10px; } #right_container { width: 200px; background: #252527 url('../images/background_img.jpg'); height: 400px; float: right; text-align: center; border: 1px solid #fff; -moz-border-radius-bottomleft: 10px; border-bottom-left-radius: 10px; -moz-border-radius-topleft: 10px; border-top-left-radius: 10px; -moz-border-radius-bottomright: 10px; border-bottom-right-radius: 10px; -moz-border-radius-topright: 10px; border-top-right-radius: 10px; } #container { background: #252527 url('../images/background_img.jpg'); width: 560px; min-width: 560px; margin: 10px auto; height: 400px; border: 1px solid #fff; padding: 0px 10px 0px 10px; -moz-border-radius-bottomleft: 10px; border-bottom-left-radius: 10px; -moz-border-radius-topleft: 10px; border-top-left-radius: 10px; -moz-border-radius-bottomright: 10px; border-bottom-right-radius: 10px; -moz-border-radius-topright: 10px; border-top-right-radius: 10px; } </style> <script> </script> </head> <body> <div id="content_wrapper"> <div id="left_container"> <?php if(isset($left_sidebar)){print($left_sidebar);} ?> </div> <div id="right_container"> <?php if(isset($right_sidebar)){print($right_sidebar);} ?> </div> <div id="container"> </div> </div> </body> </html> I put everything into a #content_wrapper div. The reason for that is because my left and right 'container' divs are floated left and right, so when you zoom out of the browser the 2 sidebars would have stayed floating - making the layout messed up. Change #content_wrapper div to whatever maximum width needs to be of the 3 columns, taking into account margins and paddings of those divs. Change the sizes of your left and right divs and make the wrapper div 940px as you need it to be. Add your footer OUTSIDE of the 'content_wrapper' div to make sure it spans 100% of whatever resolution the user is browsing in. Put it in a test file and see what it looks like in comparison to what you want to achieve. Hope this helps. Just gives you a bit of an idea of how to do it. Kind regards, L2c.
-
Can you post a live link or your relevant HTML and CSS? We can help you much better if we have something to work with or all the relevant style declarations. Kind regards, L2c.
-
With your second question, create anothe field in your table of varchar type. Then just save $_FILES['photo']['name'] to a variable (like you have done with your $_POST data) and then amend the query. Then to use the files later, you can st up a variable holding the path, then just loop though your images from the database like so: //do query to get data from that table.....save it into variable $query $directory = "/home/XXXX/public_html/images/catalog/"; while($row = mysql_fetch_array($query)) { echo "<img src='{$directory}{$row['image_field']}' alt='altText' />"; } Hope this helps, Regards, L2c.
-
Not sure what the problem could be to be honest but give this a go: //Writes the information to the database $result = mysql_query("INSERT INTO catrep (nameid,namepart,nameiphone,namefix,namedescription,nameprice,photo) VALUES ('{$ID}','{$displayname}', '{$iphone}', '{$fix}', '{$description}','{$price}','{$pic}')") ; //Writes the photo to the server if($result != FALSE && move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['photo']['displayname']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } Just overwrite everything starting from your query to the end of the script with this. Also, try putting a var_dump($_POST); statement at the top of your script and see what that reveals. Although I don't see any problem with the form input names and your $_POST data retrieving. With your second question, create anothe field in your table of varchar type. Then just save $_FILES['photo']['name'] to a variable (like you have done with your $_POST data) and then amend the query. Hope this helps, Regards, L2c.
-
Rather than using margin left, because you have positioned it as 'fixed' you can change the 'right' property. Try this: .fixed-head { position: fixed; top: 170px; right: 0px; } This will position your div directly in contact with the right hand side of the browser. Just change the value to what you need. I just viewed your source code and I don't think you need this: <div class="tile-group tile-drag" style="position: relative;">. I wouldn't mind betting that you've used software such as wordpress or similar? Hope this helps. Kind regards, L2c.
-
This would set the margin-top to 10 pixels. The shorthand CSS for margins is like this: margin: top right bottom left; edit: sorry I realize now you were identifying the CSS for him. Regards, L2c.
-
Hi guys, I am creating a website which allows the users to upload their own gaming demo recordings. I have 2 sidebars (left and right) and a main content area. In the right sidebar, I'd like to add some general information from the database, such as latest 5 members, latest 5 demos uploaded etc. I want to put a poll under that information asking my users about which game they would like to see added to the website. I'm really not sure on how to achieve this because I can't just process it like a normal form then send them back because they will be able to re-submit the poll form. How do I disable/hide the poll form depending on whether that certain user has already voted on the poll? I know it's something to do with checking the session when processing the form. Could one way be to add another field in my members table, let's say 'poll' and populate it with a value of FALSE. Then when processing the poll form data, use their username to identify the correct row and then change the value from FALSE to TRUE. Then before displaying the poll, do some checking to see if that user's column is set to TRUE and if it is then I hide the form, if it is still set to FALSE then display it? Looking at it, I think that could work maybe but I wanted to know if there is a more efficient way. I want the least amount of queries as posible and I'm terrible with joins. I haven't wrote any code so far so I can't provide any code unless you want to see my setup. Thank you in advance for any help. Kind regards, L2c.
-
Ah my bad. Thank you very much for clearing that up. I thought the foreach was meant to loop inside the while loop. I thought he needed the curly braces because I thought he was trying to execute more than one line of code also. Thanks again. Kind regards, L2c.
-
You didn't open any curly braces for your foreach loop. I'm not sure if that was the problem but I added them in. Give it a try: if(isset($_POST['search'])){ $s = $_POST['start']; $end = $_POST['end']; if($s == ''){ echo "invalid Entry"; } else{ $s = date('Y-m-d', strtotime(str_replace('-','/', $s))); $end = date('Y-m-d', strtotime(str_replace('-','/', $end))); $r = mysql_query("SELECT * FROM transaction WHERE username = '$_SESSION[username]' AND date LIKE '$s' AND $end ORDER BY date DESC") or die(mysql_error()); $num_rows = mysql_num_rows($r); print "There are $num_rows records.<P>"; echo "<center><table border='1' bordercolor='#000000' cellpadding='1' cellspacing='1'> <tr> <th>Trans ID</th> <th>Trans Ref</th> <th>Sender Acct</th> <th>Receiver Acct</th> <th>Trans Status</th> <th>Date</th> </tr>"; while ($get_info = mysql_fetch_row($r)){ print "<tr>\n"; foreach ($get_info as $field) { print "\t<td><font face=arial size=2/>$field</font></td>\n"; print "</tr>\n"; } } print "</table>\n"; print "<br>"; mysql_close($link); } } Hope this helps you in the right direction. Regards, L2c.
-
Not sure if it will make any difference but you have ended your if else statement with a semi-colon. Delete the semi-colon. Kind regards, L2c.