Jump to content

684425

Members
  • Posts

    66
  • Joined

  • Last visited

Posts posted by 684425

  1. Why do the numbers have to be random? Do they just have to be random-looking, or is it important that they are indeed unpredictable?

    just random looking and unique, because a registered user will need that account number to login to his account.

     

    One thing is for sure: Random and unique and only 7 digits long will be difficult.

    if possible and if you guide me, i want to do it. please guide  :) 

  2. not this because it generates alphanumeric random output and i want XY(random, unique integer, fixed length) = XY9162942 or XY6433389

     

    Sorry i forgot to mention fixed length in previous post.

  3. I am trying to create a registration form where users put their name, email and password only.

     

    but i want to write an auto generated account number into database table for each user e.g; XY1234567 where XY should not change 1234567 auto generated random number and no duplicates (in numbers only).

     

    example...

     

    XY1234567

    XY2345678

    XY2233455

     

    i found code

    $num_of_ids = 10000; //Number of "ids" to generate.
    $i = 0; //Loop counter.
    $n = 0; //"id" number piece.
    $l = "AAA"; //"id" letter piece.
    
    while ($i <= $num_of_ids) { 
        $id = $l . sprintf("%04d", $n); //Create "id". Sprintf pads the number to make it 4 digits.
        echo $id . "<br>"; //Print out the id.
    
        if ($n == 9999) { //Once the number reaches 9999, increase the letter by one and reset number to 0.
            $n = 0;
            $l++;
        }
    
        $i++; $n++; //Letters can be incremented the same as numbers. Adding 1 to "AAA" prints out "AAB".
    }
    
    

    but its not working as i want. Any help please?

  4. <script type="text/javascript" src="clock.js">
    That assumes "clock.js" is in the same directory as the actual script being executed, which is probably not the case. Use a full path to clock.js, or a URL, like src="/assets/js/clock.js" or "http://yoursite.com/assets/js/clock.js".

     

    <script type="text/javascript" src="clock.js">
    <script type="text/javascript" src="tip.js">
    

    both these files are in same directory along with index.php

    tip.jis is working fine but clock.js don't work.

     

    You said "you're using php for inline variables. You need to pass them through a parameter function instead"

    how can i do this?

  5. Code works when...

    <script type="text/javascript">
    var currenttime = '<?php print gmdate('F d, Y H:i:s', time() + (1 * 60 * 60))?>'
    var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
    var serverdate=new Date(currenttime)
    function padlength(what){
    return (what.toString().length==1)? "0"+what : what
    }
    function displaytime(){
    serverdate.setSeconds(serverdate.getSeconds()+1)
    var datestring=montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+", "+serverdate.getFullYear()
    var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds())
    document.getElementById("servertime").innerHTML=datestring+" "+timestring
    }
    window.onload=function(){
    setInterval("displaytime()", 1000)
    }
    </script>
    

    Code not works when...

    <script type="text/javascript" src="clock.js">
    

    I want to use second option. Any help?

  6. The answer is yes, but you need to associate whatever GET requests you want to the files you want to include in addition to other files or data (content in an array?)

     

    because i am poor in english, maybe i didn't get what you exactly asked. but i will try to explain what i am trying to do.

     

    URL from my last reply http://domain.com/x=account&r=news&id=345

     

    so,

    x=account (include account.php)

     

    &r=news(include news.php within account.php)

     

    &id=345 (get content from database and display)

     

    The example given is similar, you could expand onto it in the same way.

    i did copy that example and tried to modify it but failed. because i am new to php.

     

    also i found a (mistake?) in your example.

    //variable $pages not defined.
    //i changed $pages to $links and it worked fine.
    if (isset($_GET['x']) && in_array(trim($_GET['x']), $pages)) {
    

     

     

    What i wanted is ...

    <a href="get.php?x=news">get1</a>
    <a href="get.php?x=updates">get2</a>
    <?php
    $title = "Home | page";
    
    if (isset($_GET['x'])) {
        if ($_GET['x'] == "news"){
            $title = "News | Page";
            include "news.php";
            }
        elseif ($_GET['x'] == "updates"){
            $title = "Updates | Page";
            include "updates.php";  
    }
    }
    echo "<title>$title</title>";
    ?> 

     

     but this is for GET x only. how can i add GET ??

     

    Is there a specific reason why you can't use a database? It's the best way to save and display data.

    I am using a database dear. I have explained above. :) 

  7. So - perhaps you can re-write your question using the same terms throughout to make it clearer what you want to do

     

    I did not know there is a time limit for editing a post. (misunderstanding sometimes because i am weak in english)

     

    The question was, i want to make URLs like;

    http://domain.com/x=home

    http://domain.com/x=account&r=profile

    http://domain.com/x=account&r=news&id=345

    http://domain.com/x=account&r=updates&id=567

     

    x is used for navbar and is used for any content on account page.

    I asked that can it be done using php only.? without any database connection.

  8. I have the following three links in same page.

     

    http://localhost/folder/file.php?x=link1

    http://localhost/folder/file.php?x=link2

    http://localhost/folder/file.php?x=link3

     

    i want to show URLs as they are...

     

    link1 is to include a file named "x.php"

    link2 is to include a file named "y.php"

    link3 is to include a file named "z.php"

     

    Can it be done in php only?

    PS: its not about creating hash ids. and i want to do it without any sql db connection.

×
×
  • 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.